<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>Matrix207&#39;s Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="Matrix207's Blog">
<meta property="og:url" content="http://yoursite.com/page/12/index.html">
<meta property="og:site_name" content="Matrix207's Blog">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Matrix207's Blog">
  
    <link rel="alternate" href="/atom.xml" title="Matrix207&#39;s Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
  

</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Matrix207&#39;s Blog</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="Flux RSS"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Rechercher"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-face-to-face-office" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/08/06/face-to-face-office/" class="article-date">
  <time datetime="2013-08-05T16:00:00.000Z" itemprop="datePublished">2013-08-06</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/math/">math</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/08/06/face-to-face-office/">Face to face office</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>From <a href="http://www.douban.com/note/221426825/" target="_blank" rel="external">http://www.douban.com/note/221426825/</a></p>
<p>面对面的办公室——纪念艾伦•图灵百年诞辰 1912.6.23-2012.6.23</p>
<p>（载于《上海文化》2012年第5期）</p>
<p>##一、左边的办公室</p>
<p>冯•诺伊曼教授每年换一部新凯迪拉克。早上十点，他把爱车停在帕尔玛物理实验室门口，神采奕奕地走进隔壁数学系的办公室。那时候普林斯顿高等研究院才刚成立，和数学系挤在一幢叫作Fine Hall的楼—— “还不错的楼”。冯•诺伊曼教授总是穿一身笔挺的西装，以免别人把他错当成学生。他太年轻，三十出头，却已经到达了学术顶峰，和五十多岁的物理学家爱因斯坦、数学家维布伦(Oswald Veblen)、数学家亚历山大(James Alexander)一起成了高等研究院最初任命的四位教授。</p>
<p><img src="http://img3.douban.com/view/note/large/public/p221426825-1.jpg" alt="John von Neumann, 1903-1957"></p>
<p>十八岁那年，他犹太裔的父母试图把长子拉出对数学的执迷学些更实际的东西，于是他们达成了妥协，冯•诺伊曼同时在三所大学注册：在苏黎士联邦理工学院（ETH）学习化学工程，每晚完成柏林大学数学专业的作业，在每个学期末回布达佩斯大学参加他从没上过课的数学考试。二十二岁那年他不但从苏黎士联邦理工拿到化学工程学位，还通过了大卫•希尔伯特坐镇的数学博士答辩。整场答辩希尔伯特只问了一个问题：“我从来没见过这么漂亮的晚礼服，你的裁缝是谁？”于是，大家都知道了，希尔伯特钦点的年轻人，不但写了完美的博士论文，还是个翩翩佳公子。</p>
<p>博士毕业后的三年，高产的三年！他在柏林大学和汉堡大学的三年一共发表了二十五篇论文！包括一本八十年后仍然重印的量子力学教科书，可是……对于这个高速前行的天才这些光荣也已经是陈年往事。二十七岁上，纳粹刚刚抬头而美国也恰好走出了大萧条，维布伦代表普林斯顿去欧洲招兵买马，工资开价是冯•诺伊曼在德国挣的八倍还多。踏进美利坚第一天，他打趣地对同行的匈牙利老乡维格纳(Eugene Wigner, 1963年诺贝尔物理学奖)说：“我们该让自己更像美国人。”当即，维格纳改名叫“尤金”(Eugene)，冯•诺伊曼改名叫“约翰”(John)，和稍微熟一点的人就勾肩搭背地说“你们叫我强尼(Johnny)吧。”</p>
<p>强尼，强尼。强尼•冯•诺伊曼就不着痕迹地混进了满大街都是强尼的美利坚大熔炉，还有谁知道他刚出生时那个卑微的匈牙利名“亚诺斯”(Janos) ？还有谁知道他在德国那几年日耳曼化的“约汉纳”(Johann)？ 不过他改了名字，却死活不肯把姓氏里的“冯”去掉。二十几年前他有钱的犹太老爸向行将就木的老皇帝弗朗茨•约瑟夫买了这个贵族称号，于是带着暴发户气息的诺依曼家族就转眼变成了代代相传的贵族冯•诺伊曼，多亏奥匈帝国国库空虚等钱用，否则十足的犹太血统怎么能捐上这个高贵的名头？一到周末冯•诺伊曼肯定请教授们上他宽敞奢侈的大宅喝酒跳舞，宾客盈门杯觥交错， “冯•诺伊曼请客谁不去！”讲出这话，就好象请客做东的是奥匈帝国的某个最尊贵的日耳曼裔公爵。</p>
<p>##二、右边的办公室</p>
<p>冯•诺伊曼教授对面的办公室坐着博士生艾伦•图灵。开朗外向的冯•诺伊曼教授和孤僻紧张的图灵没什么闲话好聊，只知道这个总穿一身乱糟糟运动衫的年轻人前几天差点把自己的那部二手福特车倒车进了卡耐基湖。冯•诺伊曼教授横穿大西洋必买头等舱，常年西装革履，每年换一部崭新的凯迪拉克，略略发福，讨厌运动，有一次妻子想让他学滑雪他恼羞成怒甚至以离婚威胁。与他恰恰相反，博士生图灵则在几个月前坐着末等甲板舱从英国漂到美国。他常年一件套头衫，开一部状况堪忧的二手福特，身材瘦削，热爱运动，是跑赢过奥运会选手的马拉松健将。一到周末，他和同学打垒球比赛，分成两个队，“大英帝国队”对决“叛变殖民地队”。</p>
<p><img src="http://img3.douban.com/view/note/large/public/p221426825-2.jpg" alt="Alan Turing, 1912-1954"></p>
<p>刚来普林斯顿那会儿他不是没试过去交朋友，拥抱新生活，可是上个月当一名卡车司机理所当然地把自己油腻腻的手搭在他肩上直呼其名和他侃大山时，堂堂剑桥大学国王学院的毕业生着实为这种粗鲁的风气吓了一跳。别误会了，他不像冯•诺伊曼教授那样公子派头，他爸爸不过是大英帝国驻印度的一个小公务员，可是英伦岛国的教养让他觉得一个陌生人把脏手搭在你他肩上实在有点亲昵过分。他也讨厌陌生人叫他“艾伦”，还是“图灵先生”更妥当些。除了难以适应美国的新环境，图灵先生还有更糟的问题，在那个年代的体面社会里止于手势和眼神的问题：喏，你知道的，他有点那个……就是那个……那个啊……你晓得我在讲什么啊。</p>
<p>数学天才艾伦•图灵先生是个无可救药的同性恋。</p>
<p>这个无可救药的问题是这样开始的：当图灵还在谢伯恩男校 (Sherborne School )读高中，他认识了比自己高一级的克里斯托弗•马尔孔 (Christopher Morcom)。瘦弱的、过于瘦弱的马尔孔，每个学年都因病长期缺课，可他聪明的头脑竟然使他在偶尔上学的几天能补上所有功课，门门考试成绩第一。是这样毫不费力的聪慧吸引了图灵，而当他更接近马尔孔，惊喜地发现他和自己一样，对科学有着自发而浓厚的兴趣。在马尔孔偶尔上学的日子里，他们坐在相邻的座位听课，又一起去图书馆写作业，以便能不断讨论科学问题：马尔孔说如何在家里搭化学实验室研究碘，图灵说如何手算圆周率到小数点后36位，马尔孔说你知不知道薛定谔的量子力学有趣极了，图灵说你知不知道爱因斯坦的相对论也有趣极了。他们谈梦想，应该做数学家还是物理学家，如何为科学做出真正的贡献……晚钟响了，他们回各自的宿舍睡觉，又在凌晨爬起来站到阳台上用天文望远镜看星星，并写信把观测结果告诉对方：“我从没见过更好的木星。今夜我看到了五个环，甚至能看清中间那个环上的斑。”“我今夜看到了仙女座，但一会儿就消失了。”那个冬天，毕业班的马尔孔已顺利拿到了剑桥三一学院的奖学金。图灵还有一年毕业，马尔孔鼓励他来年报考剑桥，“因为那里的科学最好，而且我能经常看见你。”这句嘉勉说出口不到一个月，一个晴朗的凌晨，图灵起床看见月亮刚巧经过对楼马尔孔的窗户落下。“今晚的月亮格外美。”他写在记事本上预备第二天告诉马尔孔，他还不知道永远不会有那一天了。那个凌晨，克里斯托弗•马尔孔暴病夭折。</p>
<p>落葬日，时年十七岁的图灵怀着巨大的悲痛写信给马尔孔的母亲：</p>
<p>1930年2月15日<br>亲爱的马尔孔太太，<br>我因为克里斯而很难过。一年来我们一起学习，我从来没交过像他那么聪明、迷人、又谦卑的朋友。我和他分享了研究的乐趣还有对天文的热爱（这是他引发的），我想他也是这么觉得的。现在，尽管有一部分乐趣因为他的死而消逝了，即使这一切不再因为他而那么有趣，我也要投入尽可能多的精力到研究上，就象他仍然活着。他会希望我这么做的。我深知你此刻的悲痛。<br>你忠诚的，<br>艾伦•图灵<br>又及：如果你能给我一张克里斯的小照片我将十分感激。我愿以此来缅怀他的榜样和成就，督促我更仔细更优秀。我会思念他的面容，他走在我身边时微笑的模样。幸好我保存着他所有的信。</p>
<p>马尔孔死后一年，图灵的未来决定了，他要去剑桥国王学院学数学，就像给马尔孔太太的信里所承诺的，“以此缅怀他的榜样和成就。”这一年中，无数次对马尔孔的哀思恐怕也让他渐渐明白了比友谊更深的感情。是爱情吗？图灵无法回答，也不屑回答。落葬日那封痛切的信，还有这一年来（以及他的余生）为了纪念马尔孔而突飞猛进的学业都说明了这份感情比爱情更高：他在竭尽所能挽留死者。又有谁会为那么美好的感情而惊慌呢？于是图灵坦然接受了，并在余生从未试图遮掩自己的性取向。</p>
<p>##三、希尔伯特的落日</p>
<p>每个清晨和黄昏，图灵习惯一个人沿着河边长跑思考问题。去年夏天，当他还在剑桥国王学院读本科，某次长跑到精疲力竭地躺倒在草地上，斜阳西照，运动让他神思凝聚，他脑中经历了一场风暴，忽然意识到了回答希尔伯特判定问题（Entscheidungsproblem）的办法。他兴奋地一跃而起跑回寝室写下自己的思绪。他的身后，照耀世界数学界三十余年之久的希尔伯特的太阳，终于落山了。</p>
<p>大卫•希尔伯特，那个时代最受尊敬的数学家，凭一己之力使数学走上了更严谨系统的现代之路。1900年，38岁的希尔伯特如一位新任的武林盟主，振臂一呼，四方响应。他在国际数学大会上提出了著名的“二十三个问题”，立即成为了数学界集体奋斗的目标，其中的第八个问题黎曼猜想/哥德巴赫猜想更是成了数学的桂冠。二十八年后，暮年的希尔伯特又提出了三个数理逻辑上的大问题，简单说来这三个问题分别是：1）数学是完备的吗？2）数学是相容的吗？3）数学是可判定的吗？其中的第三问题，即被称作希尔伯特的判定问题。如果说 1900年的二十三个难题洋溢着壮年人的踌躇满志，那么1928年的三个问题已经是一个老人对秩序和条理的向往。希尔伯特十分希望，这三个问题的答案都是肯定的，因为这将使数学建立在完美严谨的逻辑的基石上，作为亘古不变的真理存在。</p>
<p>可惜，这个井井有条的逻辑美梦只做了三年，年轻的奥地利人哥德尔就发表了震惊数学界的哥德尔不完备定理：数学不可能既是完备的又是相容的。这个定理以十分有趣的形式否定了希尔伯特1928年的第一和第二个问题。到1935年夏天，躺在草地上休息的图灵经历了一场头脑风暴，他想到了否定希尔伯特第三个问题的办法：用机器。他想象着一种虚构的“图灵机”，可以从一条无限长的纸带子上的读取命令进行操作，从而模拟人类所可能进行的任何计算过程。图灵证明，我们不能用一个算法来判定一台给定的图灵机是否会停机，所以停机问题是一个无法判定的数学问题，即希尔伯特的第三个命题答案为否。</p>
<p>巧合的是，第二年春天，正当图灵把关于判定问题的论文初稿交给导师纽曼(Max Newman)过目时，大洋彼岸，普林斯顿大学的阿隆佐•邱奇(Alonzo Church)教授——逻辑界数一数二的学者——抢先一步发表了新论文，利用自创的λ演算(lambda calculus)否定了希尔伯特判定问题。看到邱奇如此巧合的论文，导师纽曼顺水推舟写信推荐图灵去做博士生。1936年夏，邱奇的新博士生图灵来到了普林斯顿。</p>
<p><img src="http://img3.douban.com/view/note/large/public/p221426825-4.jpg" alt="图灵在普林斯顿大学的档案 Firestone Library, Princeton University, June 2012"></p>
<p>11月，图灵关于判定问题的论文，即多年后将声名大噪的 On Computable Numbers, with an Application to the Entscheidungsproblem 终于发表，学界反应极其冷淡。12月图灵在普林斯顿数学俱乐部做了关于这篇论文的演讲，听众不足十人。这篇解决了希尔伯特第三个问题的论文为何遭到如此冷遇？有几个原因：其一，哥德尔不完备定理如此有趣奥妙，已经吸引走了学界关于希尔伯特三问题的大部分兴趣；其二，邱奇当年春天的论文已经率先解决了希尔伯特判定问题，虽然图灵的解法天差地别，也比邱奇的解法简洁得多；其三，用“机器”解决数理逻辑问题，实则是此篇论文最闪光的部分，可是过于新颖，不容易被主流学界接受；其四，恐怕也是最重要的原因：和著名教授邱奇比起来，图灵才初出茅庐。他在家书中愤愤说：“只有名人才会吸引听众。(One should have a reputation if one hopes to be listened to.)”</p>
<p>不，不完全如此。至少还有一个人会认真阅读无名小卒的论文。对门办公室的冯•诺伊曼教授——图灵默默仰慕又羞于开口的偶像——不但认真读过这篇论文，还读过所有期刊上的所有论文。他是一本雄心勃勃的百科全书，任何人的任何知识都逃不出他的法眼。图灵的论文一发表，敏锐的冯•诺伊曼已经嗅到了图灵机广阔的远景，他对朋友说，你该去找我对门的图灵，他那篇论文正好可以做这样那样的事。他慷慨地给朋友建议，自己却没亲自找图灵聊聊。他的注意力在有趣的图灵机上停留了一下，又跳到另一个截然不同却同样有趣的问题上：量子力学、流体力学、博弈论……世上千千万的问题都吸引着冯•诺伊曼，他脑中有千千万要实行的计划——图灵机不过是其中一个。</p>
<p>可是，博士生图灵仍然因为这篇论文而给冯•诺伊曼教授留下了印象，两年后图灵从普林斯顿博士毕业，是冯•诺伊曼教授唯一提出了挽留：年薪一千五百美元聘图灵做自己的助手。对于一个年轻的数学家，能师从传奇般的冯•诺伊曼教授是梦寐以求的机遇， 一千五百美元的薪水也比图灵在英国能找到的教职待遇好得多。图灵拿着冯•诺伊曼的聘书在普林斯顿校园里晃荡，理性使他不得不好好考虑这个千载难逢的肥缺，可是啊——英国人图灵吸吸鼻子，鼻子里呼到的空气有点太粗鄙，清清耳朵，耳朵里听到的英语有点太懒散。他走过哥特式的普林斯顿校礼拜堂，那只是更加宏伟古老的剑桥国王学院礼拜堂蹩脚的复制品。礼拜堂的尖顶插入新泽西州的蓝天白云，英国人图灵却没法欣赏这儿的晴空万里，他的目光越到了大西洋彼岸，那里，纳粹的阴云密布欧洲。</p>
<p>1938年夏，博士毕业的图灵忧心忡忡回到英国剑桥，在数学系做一学期才给十英镑的临时教员，教一门听者寥寥的“数学基础”。他将慢慢攀爬学术的梯子，成为教员、讲师、副教授、教授，如果不出意外的话。九个月后，意外降临：纳粹的阴云终于骤降成狂风暴雨，德国入侵波兰，第二次世界大战开始。</p>
<p>##四、Station X. Site Y.</p>
<p>二战的爆发给白金汉郡的布莱切利镇带来了点可喜的新鲜，一万多人连夜从大城市挤火车逃难到这个平庸乏味的小镇，可是不久大部分又挤火车回去了：宁愿被炸弹炸死，也不要在这小地方无聊死。艾伦•图灵却逆着人潮，搬到了这无聊小镇最无聊郊区的一家最最无聊的小旅馆里，每天骑车三英里去镇中心的布莱切利园(Bletchley Park)上一个谁都不知道在瞎搞什么的班，下班回来还自愿给冷冷清清的旅馆酒吧打杂。旅馆老板娘看着这个闲得发慌的小伙直摇头：健健康康的大男人，怎么不去打仗呢？</p>
<p>可是，图灵正在打仗。他的敌人：哑谜。看似死水一潭的布莱切利园，此时已有了军事代号：Station X，保密等级：绝密。这里是英国政府密码学校的驻地，海陆空和军情六处的情报组织各占一隅。几百名工作人员日夜兼程破解德国人的无线电报，为了最大程度保密，大部分职员根本不知道工作的真正目的，除了几个核心解密成员：象棋冠军、填字游戏高手、数学家。二十七岁的图灵很快在这个核心团队里有了绰号：教授(Prof.)。</p>
<p>此时的欧洲上空，无数来自德军的电波正以莫尔斯码的形式穿梭来回。这些莫尔斯码发出前由一种称作“哑谜机”(the Enigma Machine)的加密器加密，在接受方又由同样的“哑谜机”解密。直到二战结束，德军从未怀疑过哑谜机的坚不可摧，所有军种所有级别电报，一律用哑谜机加密，加密电报中放心大胆地沟通了所有军事信息：潜艇位置、军队人数、攻击路线、伤亡报告……</p>
<p><img src="http://img3.douban.com/view/note/large/public/p221426825-5.jpg" alt="哑谜机"></p>
<p>德军的信心源于哑谜机复杂的加密方法。虽然每个军种对商用的哑谜机都略有改进，不过所有哑谜机基本构造相同：键盘、接线板、多个转子、指示灯。当密码操作员在键盘上按下一个字母（比如字母A），电流会通过一个可自行改接的接线板，启动一个或者多个转子转动，同时点亮某个字母指示灯（比如字母L），于是字母A被加密成字母L。哑谜机精巧的设计使得，在下一次按下字母A时，它将被加密成另一个不同的字母（比如字母P）。更巧妙的是，当且仅当发送端和接收端的哑谜机拥有同样的初始设定（同样的接线板、同样的转子排列、同样的转子初始位置），密码L才可以使用接收端的哑谜机还原成A。而对于不知道初始设定的敌方，他们面对的可能情况多达10^114种！</p>
<p>雪上加霜的是，德军每个军种所用的哑谜机略有不同，相对于三个转子的陆军哑谜机，海军五转子的哑谜机要复杂得多。在布莱切利园只有两个人相信这层层加密状如天书的密码可以被破解：一个是布莱切利园的老大，因为“海军电报必须被破解”，否则被德军潜艇战封锁的英国将坐以待毙；另一个是“教授”图灵，因为“如果海军电报能破解，那实在太好玩了”。</p>
<p>“教授”发现，在加密文件中找规律的本质是重复搜索，而搜索是一种机器可以代替人脑的工作。当时，布莱切利园从曾经研究过哑谜机的波兰数学家那里继承了一种叫“炸弹”(Bombe)的原始解密仪器，每一个“炸弹”模仿一个哑谜机的转子，许多“炸弹”相链接来模拟一种哑谜机的初始设定生成可能的电报。简而言之，这是一种穷举搜寻答案的算法，需要遍历所有可能排列，费时费力。图灵洞察到，只要运用几个简单的事实——比如，一个字母的密码不可能是其本身、原始文本中一些字母（比如s）的出现频率一定高于另一些字母（比如x），一些固定词语（比如“元首”）将高频出现——就能大大改进波兰人的笨法子，来快速寻找最有可能的转子设定。用现在的算法语言来说，他将穷举法改良成了贪心算法。贪心算法改进后的“炸弹”对抗五转子的海军哑谜机大获成功。每次一方发出电报后，接受方过几分钟将发一封短电报表示“收讫”。许多回，电波中还未监测到“收讫”电报，图灵的“炸弹”机已经将密码还原成了原文， 可见“炸弹”的解密速度甚至比预知原始设定的接受方都快！布莱切利园自豪地说，德国人真该问“教授”他们的电报到底讲了什么。</p>
<p>可是，随着战争深入，转子更多的哑谜机不断投入运用，最后竟出现了十二转子的密码机。面对十二转子，即使图灵的“炸弹”都需要十几天时间。战场瞬息万变，布莱切利园亟需更快速的机器。很显然，提高速度的关键在于把机械的“炸弹”机改成更快速的电路装置。1943年，在图灵的鼓励下，布莱切利园工程师Tommy Flowers设计了一台叫作Colossus的巨型机器，在战时充裕的经费支持下很快获准建造。</p>
<p>这就是世界上第一台计算机，电子化、数字化、程序化。它由光学在长条纸带上读取电报原文，经过一千五百个真空管的电路计算，将解密结果输出到电传打字机上。1944年6月1日， 经过完善的Colossus二号机抵达布莱切利园。离诺曼底登陆只有五天。</p>
<p>诺曼底登陆，在欧洲开辟第二战场的唯一方法，毋宁是一场豪赌。盟军三百万主力兵力要从海上和空中登陆易守难攻的诺曼底，很可能伤亡惨重。为了保护兵力，盟军的情报网精心编造了一则假情报透露给敌方，希望德军以为在诺曼底将有一次只是“小规模”的军事转移。而德军能不能上当则唯有通过由Colossus解密的德军电报检验。幸亏快速的电子计算机，解密很顺利，德军的电报显示只有一小支部队被派往诺曼底。更幸运的是，电报还详细说明了军事安排、物资转移、军种调遣，德军手中的牌一览无余。</p>
<p>6月6日凌晨三点，Colossus破解了一条德军自诺曼底刚发出的绝望的电报。天啊，天上怎么来了那么多伞兵。</p>
<p>随着这些伞兵安然降落，二战的转折点到来了。</p>
<p>大西洋的另一边，1943年秋。</p>
<p>威斯康辛大学麦迪逊分校数学教授乌拉姆(Stan Ulam)的办公室里闯进了一个女学生。学期只过了一半，她却要求提前完成期末考试，以便“为战争服务”。她坐在办公室的地板上，答完了教授在信封背面临时写下的几道题，然后消失到谁都不知道哪儿去了。</p>
<p>这几天，乌拉姆身边有许多朋友消失了。在食堂认识的同事、物理教授、自己带的研究生，他们打了个 “为战争服务”的假条，就神秘莫测地走了。乌拉姆心里痒痒，写信给自己朋友中人脉最广的冯•诺伊曼，询问有否能为战争服务的工作，他回信了，说自己忙得很，不如在芝加哥火车站见面——他在那里正好有两个小时的转车时间。乌拉姆在站台见到了风风火火的冯•诺伊曼，以及——他身后的两位保镖，这才意识到他朋友正在忙活的事对大战意义重大。冯•诺伊曼神秘地表示：有一件很重要的项目也许能让乌拉姆帮忙，不过他还不能说是什么事，在哪里，有谁。</p>
<p>几周后，乌拉姆收到了一封政府委派信，要求他去新墨西哥州一个小镇。他从来没听说过这荒僻之地，就去图书馆借新墨西哥州地图册。于是他惊喜地发现，在地图册的借书卡上，整齐地排列着之前消失的所有熟人的名字。他们都消失到了这个闻所未闻之地。</p>
<p>火车在一个荒凉的车站停下，黄沙遍野，峭壁陡崖，像时间尽头一样死寂。这里就是Site Y，刚刚起步的研究项目叫Project Y，保密等级：绝密。战争结束后，前者将称为洛斯阿拉莫斯国家实验室(Los Alamos National Laboratory)，后者便是鼎鼎大名的曼哈顿计划。在这片萧索瑰丽的沙漠中，聚集了一群活力旺盛的年轻人，平均年龄25岁，第一年，80个新生命诞生。他们的领袖奥本海默38岁，他们的信使冯•诺伊曼39岁。他们的任务：制造摧毁一切活力和生命的超级武器，原子弹。</p>
<p><img src="http://img3.douban.com/view/note/large/public/p221426825-7.jpg" alt="洛斯阿拉莫斯国家实验室边界的标志"></p>
<p>四年前，爱因斯坦和西拉德（Leo Szilard）上书美国总统罗斯福：物理学的推进已经使得通过核裂变获得巨大能量指日可待，只要德国人愿意，他们有知识和能力发明这种武器，美国必须赶在纳粹德国之前掌握核技术。随着美国正式参战，核技术的研究越来越紧迫。一个名字被提出来：罗伯特•奥本海默，聪明果敢，当机立断。另一个名字被提出来：约翰•冯•诺伊曼，因为他已经坐镇另外十几个军事项目上，正好能耳听八路，眼观四方。</p>
<p>冯•诺伊曼教授是军方最喜爱的合作人。作为犹太人他对纳粹嫉恶如仇，为了替关在集中营的朋友报仇他渴望和手段强硬的人合作，醉心各种新式武器。作为数学家，他认为只有当数学有应用价值时，数学才能最快速度发展。少时父亲逼迫之下学习的化学工程意外派上了用场，他很容易明白物理学家和化学家的讨论，再用数学的语言解释给数学家听。他最擅长把一项看似庞大无解的任务庖丁解牛，分拆成小零件委派他人，让底下每个人觉得自己拿到的那部分恰好是最擅长的本职。他是天生的领袖和传令官，坐镇导弹研究实验室、美国数学学会战争委员会、国家防御研究委员会……不像大多数被强制定居在洛斯阿拉莫斯的科研者，他进出自由。日理万机的冯•诺伊曼教授哟，他在普林斯顿、波士顿、费城、华盛顿、芝加哥、洛斯阿拉莫斯实验室、阿伯丁兵器试验中心……全美的战时科研进展他一清二楚，人家刚跟他讲了两句，他就能接上来，“某某在芝加哥也做这事。”“哈佛的某某已经搞出来了。”</p>
<p>曼哈顿计划最大的困难不是制造出核裂变反应，而是控制原子弹的威力。爆炸的冲击波将反复震荡叠加，最终的力量难以预测。曼哈顿计划的高度机密性和核试验的昂贵成本使得大规模试验不可能，而人力又难以计算如此多的非线性方程。如何提高计算能力成了当务之急。</p>
<p>事实上，计算能力这个瓶颈也困扰着其他军方科研项目。于是，1943年，当听说宾夕法尼亚大学的一群工程师为了计算导弹轨道（另一种典型的非线性方程）而开始建造一台名为ENIAC的巨型机器时，冯•诺伊曼立即敏锐地想到：也可以用这机器去计算原子弹冲击波的能量。在他的牵头下，ENIAC建完后第一项测试任务居然不是导弹轨道而成了核弹方程，整个测试将原本几个月的 人力计算缩短到了几天。完成测试他脸色苍白地回到普林斯顿家里倒头睡了十小时，醒来后不吃不喝，久久向妻子吐出一句话：“我们造了一头怪兽。”</p>
<p>怪兽，他指的不是核弹，而是计算机。</p>
<p>看到了ENIAC的广阔前景后，冯•诺伊曼毛遂自荐要做ENIAC的数学顾问，让发明者Presper Eckert和John Mauchly受宠若惊。他们亲自领冯•诺伊曼参观机器，一间两百平米的大房间里，两个工程师指给他看：这里是一万八千根真空管、这里是电源、这里是读卡器、这里是维修站……可是，人家的设计冯•诺伊曼却看得比设计者还清楚，他一回去就写了个105页的报告：“一台计算机的基础组成是：存储器、控制器、运算器、输入输出设备。”至今，世界上的大部分电脑仍在沿用这著名的“冯•诺伊曼结构”。</p>
<p>1945年5月，德国投降，证据显示德国当时的科研进展还未能制造出原子弹。7月，洛斯阿拉莫斯第一颗原子弹试射成功。8月，在新上任的杜鲁门总统的授意下，两颗本为抵御德国人的原子弹投向日本广岛和长崎。9月，日本投降。第二次世界大战结束。</p>
<p><img src="http://img4.douban.com/view/note/large/public/p221426825-8.jpg" alt="1945年7月16日凌晨，第一颗原子弹Trinity在新墨西哥州试射成功。"></p>
<p>##五、MANIAC</p>
<p>在二战的巨大压力下，英美两国独立制造出了最原始的计算机，Colossus和ENIAC。它们惊人的相似：都利用打孔卡输入，都运用真空管计算，都体积庞大，都对二战胜利功勋卓著。二战史学家普遍认为，布莱切利园的工作使欧洲战场缩短了一年半到两年的时间，并直接切断了“沙漠之狐”隆美尔在北非的补给线；而曼哈顿计划则终结了太平洋战场。现在，在这个戏剧性的擂台上，两个核心人物图灵和冯•诺伊曼都决心改进这两台原始机器相似的缺陷：只为专门目的设计，不能储存程序。改进的方向很明显，一如图灵1936年论文所预言的那样，造一台能完成任何目的的图灵通用机。</p>
<p>二战结束了，而冷战的阴影旋即逼近。核威慑成了一扇关不上的门，在间隔重重的美苏关系中，美国很快发现为求自保只能继续扩大核优势。氢弹的研究成为了攻坚关键，而如何提高计算能力又成了重中之重。要造一台好机器！冯•诺伊曼教授对此深信不疑。</p>
<p>在哪里造？就在普林斯顿高等研究院！高等研究院院长面有难色：“我们这儿一直搞纯科学，造这么台大机器有点不像话吧？”“钱哪来？一年十万美金的预算，你得让数学系经费翻三番！”“造了放哪？三间两百平米的大房子，二十四小时引擎折腾，我们这儿可没这样的兵工厂。”鬼精明的冯•诺伊曼笑着对院长说既然这样那就算了，谢谢院长费心，一回头却给哈佛大学、芝加哥大学、IBM轮番写信：“我有兴趣到你那儿工作。”三所机构喜笑颜开，发出了热烈的聘书。好个冯•诺伊曼，姜太公钓鱼，把哈佛的聘书给芝加哥看，把芝加哥的给IBM看，每个机构衬着别人的价码轮番加价，要是能把鼎鼎大名的冯•诺伊曼请到，送个金屋银屋都值！他胜券在握，把哈佛的天价聘书呈给普林斯顿的同事看，伤感地说自己要辞职，教授们联名写信给院长：“失掉冯•诺伊曼将是普林斯顿的悲剧！”那院长也只能咬咬牙：去造你那台要命的机器吧。</p>
<p>1947年在普林斯顿高等研究院开始建造的MANIAC计算机在任何意义上都超过了前任ENIAC。ENIAC用了两万个真空管，MANIAC只用了两千个。ENIAC重达三十吨，MANIAC只有一吨。最关键的是，ENIAC不能贮存程序，每个 不同的任务都需要重新排布电线，而MANIAC可以读取由打孔卡上二进制编码的程序，贮存在存储器中。它是世界上第一台真正的全能自动电子计算机，是后世所有计算机的母型。它完成的诸多军方任务中，最惹眼的是一次耗时60昼夜的计算，其结果证明了氢弹制造的可行性。</p>
<p><img src="http://img5.douban.com/view/note/large/public/p221426825-9.jpg" alt="1952年科学家们在MANIAC前合影。左五为奥本海默，右一为冯•诺伊曼。"></p>
<p>1957届校友Joshua Dranoff，日后成为西北大学化工系教授，在五十年代利用MANIAC完成了他化工博士论文，其中设计了一个用计算机模拟实验结果的步骤。他告诉我，每一天机器运行之前有漫长的检修，技术工拿着一箱电线和真空管爬进MANIAC内部逐一更换坏损零件。各个专业的学生等在实验室外叽叽喳喳地排队签到，他们都想尝尝MANIAC的鲜，在论文里时髦地用计算机做个小项目。1958届校友Jerry Porter，日后成为宾夕法尼亚大学数学系教授，是第一个运用MANIAC完成本科毕业论文的学生。他大三大四时还带领一帮同学负责MANIAC的夜班值勤，他们得盯着示波器屏幕，时刻监测MANIAC宝贵的1024比特随机存储器不被烧坏。这个夜班工作激发了他对计算机的兴趣，日后的学术生涯他专注于计算数学领域。</p>
<p>于是乎，在未受战争破坏的美国，由ENIAC掀起的计算机和电子工程科学搞得风生水起，并很快由IBM公司实现了商业运作。到1960年MANIAC光荣退休被捐赠给史密森尼国家博物馆(Smithsonian)时，全美已经拥有了6000台计算机。</p>
<p>在废墟上的英国，博士生图灵的运气远没那么好。二战后，为保护英国情报网，布莱切利园大部分文件资料被焚烧销毁，其余被归为机密档案。胜利的光荣属于海陆空三军，而布莱切利园的工作人员必须对战时工作保持沉默。头号功臣图灵被授予大英帝国官佐勋章（OBE），可即便他的母亲也只是知道，“他做了点了不起的事情。”</p>
<p>图灵被分配到国家物理实验室工作，迫不及待地想要改进Colossus。 他向实验室提交了一份项目申请，详尽地阐明自己将如何建造一台能贮存程序的计算机，事无巨细地列出所有图纸和经费计划。可是，战时布莱切利园的高效和无节制的战争经费已经让位于战后拖拉的官僚作风和经济危机。过目这份申请的负责人没有一个看出这庞然大物的用处，大部分人甚至不相信计算机可以造出来——可笑可叹，与ENIAC的风光截然不同，为情报服务的Colossus对外界是“不存在”的。图灵甚至不能告诉别人，这台他们认为不可能造的机器已经造出来了。</p>
<p>1948年，受够了国家实验室的官僚作风，图灵跳槽到曼彻斯特大学计算实验室 (Computing Labatory)，这里受到美国ENIAC的激励正在建造英国第一台贮存程序式电脑Manchester Mark I。图灵本该大有作为，可是制造这么大一个机器需要和很多人协调，他孤僻的性格很快让同事与之疏远，大部分建议被当作书呆子的意气而姑妄听之。不久，他聊以自慰地发现，造计算机的难点主要是硬件而非数学模型，那还是把琐碎的工程问题留给工程师吧。他呢，他只要能够“想”就行了。想——他开始为一个根本不存在的计算机想一种下象棋的程序。四年后，他会扮演这台虚构的计算机，严格执行自己的程序，和朋友下了一场真正的象棋比赛，每一步耗时半小时。他和朋友下输了，却赢了朋友的妻子一局。对于数学家图灵，即使永远没有计算机的实体，这件事也已经做完了。“想出来”就是“做出来”。</p>
<p>##六、咬了一口的苹果</p>
<p>在曼彻斯特大学，图灵的主要工作仍然是在计算学理论上。1950年，他提出了至今仍广泛使用的“图灵试验”(Turing Test)，即让测试者向两个对象——一个为机器一个为自然人——提出一系列问题，如果根据双方的回答，测试者不能辨别孰为机器，则这个机器应被视为有智能的。别有意味的是，图灵在提出这个试验时用了一个精巧的隐喻：假设两个回答者是一男一女，提问方在问出一系列问题后不能判断哪个是女人，则可以认为那个男人也是一个成功的“女人”。</p>
<p>他是在这里影射自己性取向上的差异吗？我们不得而知。可完成论文后没多久，他就在一次散步时结识了十九岁的阿诺德•莫里(Arnold Murray)：水泥匠的儿子、惯偷、小混混。这让人不禁想起当年中产富裕的魏尔伦一见钟情地爱上了十六岁的兰波：一个乡下来的野孩子，境遇的极端不同招至强烈的爱欲。如同魏尔伦和兰波一样，图灵的故事也有一个甜蜜的开头和一个毁灭性的结尾：有一天图灵发现自己家中失窃了，他报了案，窃贼是莫里的朋友。于是经过简单的询问，图灵向警方承认了和莫里之间的关系。</p>
<p>在当时的英国，同性恋被列为“不体面罪”(gross indecency)。他的入室盗窃案非但因此不得到法律保护，他反而被送上法庭受审。法官给出了两种惩罚任他选择：坐牢或者化学阉割。当时一些科学研究认为，同性恋源自过剩的雄性欲望，可以通过注射雌激素来抑制。两害相权，图灵选择了后者，因为这样至少能呆在家里继续做数学。他被持续注射雌激素长达一年，导致胸部发育，变声，阳痿。</p>
<p>1954年6月7日，他在家中咬了一口沾有氰化物的毒苹果自杀。</p>
<p>让图灵生命最后两年处境悲惨并最后导致他服毒自杀的“不体面罪”，他当时是极其天真地就在警方面前承认了。他不但口头承认了，还兴冲冲手写了五页花体字的供述。读过这五页纸的警察认为 “像散文一样流畅”(a flowing style, almost like prose)、“虽然有些措词太难读不懂”(beyond them in some of its phraseology)、“他真以为他在做正确的事”(he really believed he was doing the right thing) 。图灵事后告诉朋友，他之所以这么坦白是因为他以为同性恋很快就要合法了，一切都可以摊在台面上谈。</p>
<p>图灵惨死后六十年过去了，这一切还远不能摊在台面上谈，同性恋行为在大部分国家仍受到广泛争议，虽然尊重和合法的呼声在青年一代中越来越高。2009年，英国首相布朗在一份几千人签名请愿书下向这位计算机之父和二战英雄做了官方道歉：“我们很抱歉。你本该被更好对待。(We are sorry. You deserved so much better.)”</p>
<p><img src="http://img3.douban.com/view/note/large/public/p221426825-10.jpg" alt="为纪念图灵百年诞辰，今年英国发行了一张图灵邮票。"></p>
<p>1957年，五十三岁的冯•诺伊曼因骨癌病逝，癌变原因很有可能源自曼哈顿计划的核辐射。军方代表守在他的病床前，以防他在药物作用下泄漏军事机密。生命最后的日子，这个数学天才连简单的加减法都不能做了，却还逐字背诵幼年读过的《浮士德》 给探望的亲友解闷。浮士德，与魔鬼订约而遍历人间百态的大学者，这不正是冯•诺伊曼的一生？</p>
<p>冯•诺伊曼去世后，一切都不同了。曾经那么容易实现的事情，现在却困难重重。继任者们不明白，他到底是怎么搞来那么多钱？怎么招到那么聪明的人？“而且，说到底，我们为什么非得造一台机器呢？”冯•诺伊曼手下忠心耿耿的工程师们还梦想着造一台更好的MANIAC，用晶体管造，稳定性比真空管好得多……可是，这一台机器永远没造。源泉死了，源源不断的活力和创造便停歇了。普林斯顿高等研究院退出了计算机科学最令人激动的发迹史。接下来，将是IBM和MIT的天下。</p>
<p>##七、“告诉他们，我度过了极好的一生。”</p>
<p>回到1939年，大战之前的最后一个学期。</p>
<p>1939年2月13日，剑桥哲学系教授维特根斯坦走进“数学基础”课教室，失望地发现他的学生图灵今天缺席了，于是对班上宣布，因为图灵缺席，“今天的课只是参考性的”——要知道这门课的要旨就是听维特根斯坦和图灵吵架！这位27岁的年轻人刚从普林斯顿大学博士毕业，正在剑桥数学系以临时教员的身份教授一门同样叫作“数学基础”同样听者寥寥的课，不过维特根斯坦的课是关于“数学本质是什么”这个哲学问题，而图灵的课是关于“奠定数学基础的公理是哪些”这个数学问题。在维特根斯坦的课上，他喜欢把所有对数学基础的攻击倾数射向图灵，而图灵也很喜欢针锋相对地反击。两人激烈地争吵，而后发现自己对彼此领域的理解前进了一点。在这个常年一身运动衫、又紧张又内向的年轻人身上，维特根斯坦看到了三十年前的自己：除了思考最基本的问题，这世上没有其他事要做。三十年前，出生于欧洲最富有家族的维特根斯坦也是同样不修边幅地站在逻辑学家罗素面前，他急于从罗素口中知道自己有没有严肃思考最基本问题的才能：如果没有，他就预备去自杀。</p>
<p>而今天，这个与自己惊人相似的年轻人图灵没有来上课 。图灵正骑着掉链子的自行车去“钟屋”(Clock House)——他心爱的克里斯托弗•马尔孔生前最常去的教区教堂。今天是马尔孔去世九年的祭日，马尔孔的父母决定以儿子的名义为教堂捐赠一个小礼拜堂。图灵坐在礼拜堂里参加捐赠仪式，对面的彩色玻璃窗上绘有圣徒克里斯托弗的事迹。亡友死后，彻底的无神论者图灵已经几十次来到这座教堂缅怀十七岁的夜晚，他和他从图书馆回宿舍一路上所谈论的雄心壮志：如何为科学做出真正的贡献。现在，完成了剑桥和普林斯顿的学业，这个雄心已经变得更加具体。他的脑中已经看到了一部精巧的机器，一部能完成所有“可能完成的”任务的机器。这不再仅仅是一台机器，也是对马尔孔的交代。</p>
<p>多年之后，冯•诺伊曼教授会向美国政府保证，世上只需要十五台这样的机器，全部由像自己一样聪明的科学家操作，用以计算最重要的问题：弹道曲线、核反应方程、天文观测。而图灵的愿景在更深的地方：钻研过希尔伯特1928年三个问题的博士生图灵伤感地意识到，数学是不完美的，逻辑是不完美的，哲学是不完美的。即使在最抽象最笼统的意义上，我们仍然永远活在一个不完美的世界里，在这摇晃的地基上我们永远造不出任何完美的事物。我们必须不断修葺改造，在每一次稳固地基的同时试图变得更好。</p>
<p>如果一台完美的机器是不可能的，那么能否造出一台不完美但是像孩童一样不断成长的机器呢？于是，图灵梦想着他的图灵机，那是一种可以不断读取自身修改自身的机器，在许多次失败的尝试后能学习到成功的诀窍。图灵梦想着许多图灵机连接在一起，一台提出问题，许多台都可以回答。可以是任何问题：从弹道曲线到老奶奶的购物清单到家庭旅行的地图路线。可以由任何人操作：从最聪明的科学家到小学肄业生，因为每台图灵机提供答案将经过更多的图灵机甄选。</p>
<p>我们知道，冯•诺伊曼关于世界只需要十五台计算机的断言错了。世界沿着图灵的梦想延展下去，一个扁平的千姿百态的世界。我们知道，图灵的梦想已经那么熟稔地被今天的人类挂在嘴边：互联网、人工智能。</p>
<p>回到1937年，文章一开头描绘的那个早晨。</p>
<p>34岁的犹太裔教授冯•诺伊曼是家财万贯的公子哥，不过他一定是公子哥中最勤奋的一个。他每天五点起床，昨夜他派对宴请的朋友还一个个倒在沙发上打呼噜，他已经在书房里沙沙写了几页论文。九点开早饭，他停止工作走出书房，和留宿的朋友谈笑风生邀请他们下次再来。十点，他的凯迪拉克已经稳稳当当地停在帕尔玛物理实验室前面，他一身标志性的西装地走向相邻的数学楼，继续写论文。</p>
<p>此时25岁的同性恋博士生图灵也已经穿着标志性的破运动衣沿着学校树林跑完了半程马拉松。他在树林里看到了几只英国见不着的颜色鲜艳的青蛙，几朵庞大的蘑菇，暗自好笑了一会儿。他到帕尔玛物理实验室捣鼓了一下自己的业余爱好——制造一台能做乘法的机器——然后穿过天桥走进数学楼，向办公室对门的冯•诺伊曼尴尬地打个照面，继续研究λ演算和图灵机。</p>
<p>那时候，普林斯顿大学的数学楼和物理楼有一座天桥相连。爱因斯坦教授精神很好，每天穿梭天桥许多次在数学和物理之间来回奔跑。那是一个离我们遥远的伟大的科学年代，基础学科之间有许多天桥和地道相通，科学家从一个学科开始挖凿，最后挖到另一个学科的金矿。希尔伯特在世纪之初的著名演讲为几十年内的数学突飞猛进提供了指路牌，爱因斯坦1915年的广义相对论带来了一个崭新的宇宙观，一个个新化学元素接踵而至犹如上天的惊喜。集合论不过半个世纪，拓扑学才三十几年，量子力学二十年……在这个幸福的基础科学的时代，犹太人冯•诺伊曼和同性恋图灵坐在面对面的办公室里，这两种备受歧视的身份将困扰他们一生，可是此时，他们心无旁骛只有一个愿望：做一个数学家、数学家、数学家。</p>
<p>幸福的数学家。</p>
<hr>
<p>扩展活动：<br>我的一位学数学的朋友制作的图灵机网站在<a href="http://awesometuringmachine.com/" target="_blank" rel="external">这里</a>。为之所写的浪漫的使用说明书在<a href="http://blog.renren.com/blog/230154727/819611547" target="_blank" rel="external">这里</a>。<br>向对图灵的一生感兴趣的读者推荐这本科学传记的典范：<a href="http://www.amazon.com/Alan-Turing-Centenary-Andrew-Hodges/dp/069115564X/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1340369774&amp;sr=1-1&amp;keywords=alan+turing+the+enigma" target="_blank" rel="external">Alan Turing: The Enigma</a> .<br>向对哑谜机和布莱切利园感兴趣的读者推荐纪录片World War II Mind of a Code Breaker，在Youtube上有。</p>
<p>本文的写作除参考以下书目，还从1957届校友Joshua Dranoff教授、 1958届校友Jerry Porter教授处得到了宝贵的原始资料。1988届校友W. Barksdale Maynard先生、普林斯顿档案馆的Daniel Linke先生在史料核对上提供了有益的线索。<br>本文的配图除图灵在普林斯顿的档案那一张系自己拍摄，其余都来自网络。</p>
<p>参考书目：  </p>
<ul>
<li>Dyson, George. Turing’s Cathedral: The Origins of the Digital Universe. New York: Pantheon Books, 2012.</li>
<li>Hargittai, Istvan. The Martians of Science: Five Physicists Who Changed the Twentieth Century. Oxford: Oxford University Press, 2006.</li>
<li>Hodges, Andrew. Alan Turing: the Enigma. New York: Walker &amp; Company, 2000.</li>
<li>Macrae, Norman. John von Neumann: The Scientific Genius Who Pioneered the Modern Computer, Game Theory, Nuclear Deterrence, and Much More. Providence, RI: American Mathematical Society, 1999.</li>
<li>Monk, Ray. Ludwig Wittgenstein: The Duty of Genius. New York: Penguin Books, 1991.</li>
<li>Ulam, S.M.. Adventures of a Mathematician. New York: Charles Scribner’s Sons, 1976.</li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/08/06/face-to-face-office/" data-id="ciqqpe1lg0065nmpvdoxdqjyh" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/math/">math</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-opensource-projects-valued-for-reading" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/08/05/opensource-projects-valued-for-reading/" class="article-date">
  <time datetime="2013-08-04T16:00:00.000Z" itemprop="datePublished">2013-08-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/08/05/opensource-projects-valued-for-reading/">Opensource projects valued for reading</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>These days, I felt tired to do any coding. I couldn’t descript the future of it.<br>So, I tryed to looking something in the Internet, which wasn’t clear enough in<br>my mind. Then, I found this article <a href="http://www.zhihu.com/question/19589485" target="_blank" rel="external">Zhihu-Hit me hardly</a>,<br>maybe a programmer should be like that.</p>
<p>A programmer, who want to improve his/her skills not only one directory, should<br>read the projects listed as below:  </p>
<ul>
<li>Operator system kernel<br><a href="https://www.kernel.org/" target="_blank" rel="external">Linux kernel</a></li>
<li>Compiler<br><a href="http://gcc.gnu.org/" target="_blank" rel="external">GCC</a></li>
<li>Interpreter  </li>
<li>Database<br><a href="http://www.mysql.com/" target="_blank" rel="external">MySQL</a></li>
<li>Web server  </li>
<li>Web browser<br><a href="http://mozilla.org/firefox" target="_blank" rel="external">Firefox</a></li>
<li>Editor<br><a href="http://www.vim.org/" target="_blank" rel="external">vim</a><br><a href="http://www.notepad-plus-plus.org/" target="_blank" rel="external">Notepad++</a></li>
</ul>
<p>There have published two books, one is <a href="http://oreilly.com/catalog/9780596510046" target="_blank" rel="external">Beautiful code</a>,<br>introduced much beautiful code, and <a href="http://oreilly.com/catalog/9780596517984" target="_blank" rel="external">Beautiful Architectures</a><br>show lots of valued architectures.</p>
<p>Other link:  </p>
<ul>
<li><a href="http://www.aosabook.org/en/index.html" target="_blank" rel="external">The Architecture of Open Source Applications</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/08/05/opensource-projects-valued-for-reading/" data-id="ciqqpe1ld0062nmpv9r2xttoi" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/source/">source</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-networkstack-important-structure" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/07/30/networkstack-important-structure/" class="article-date">
  <time datetime="2013-07-29T16:00:00.000Z" itemprop="datePublished">2013-07-30</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/network/">network</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/07/30/networkstack-important-structure/">NetworkStack important structure</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>Version: linux-kernel-1.2.13</p>
<pre><code>File                Struct                        Description
-------------------------------------------------------------------
path: /include/linux
etherdevice.h                                     以太网协议相关函数声明
icmp.h                                            ICMP协议结构定议
                    icmphdr
                    icmp_err
if.h                                              接口相关结构定议
                    ifmap
                    ifreq
                    ifconf
if_arp.h                                          ARP协议结构定议
                    arpreq
                    arphdr
if_ether.h                                        以太网首部及标志位定义
                    ethhdr
                    enet_statistics
if_plip.h                                         并行线网络协议
                    plip_conf
if_slip.h                                         串行线协议
igmp.h                                            IGMP协议结构定义
                    igmphdr
                    ip_mc_socklist
                    ip_mc_list
in.h                                              协议号定义
                    in_addr
                    ip_mreq
                    sockaddr_in
inet.h                                            INET域部分函数声明
interrupt.h                                       下半部分结构定义
                    bh_struct
ip.h                                              IP协议结构定义
                    timestamp
                    route
                    iphdr
ip_fw.h                                           防火墙相关结构定义
                    ip_fw
                    ip_fwpkt
ipx.h                                             IPX包交换协议结构定义
                    sockaddr_ipx
                    ipx_route_definition
                    ipx_interface_definition
                    ipx_config_data
                    ipx_route_def
net.h                                             INET层关键结构定义
                    socket
                    proto_ops
                    net_proto
netdevice.h                                       设备相关结构定义
                    de_mc_list
                    device
                    packet_type
notifier.h                                        事件响应相关结构定义
                    notifier_block
ppp.h                                             点对点协议结构定义
                    ppp_lqp_packet_hdr
                    ppp_lqp_packet_trailer
                    ppp_lqp_packet
                    ppp_ddinfo
                    ppp
route.h                                           路由结构定义
                    old_rtentry
                    rtentry
skbuff.h                                          数据包封装结构定义
                    sk_buff_head
                    sk_buff
socket.h                                          常数选项定义
                    sockaddr
                    linger
sockios.h                                         选项定义
tcp.h                                             TCP协议结构定义
                    tcphdr
timer.h                                           定时器相关结构定义
                    timer_struct
                    timer_list
udp.h                                             UDP协议结构定义
                    udphdr
un.h                                              UNIX域地址结构定义
                    sockaddr_un

path: net/inet
ip.h
                    ipfraq
                    ipq 
ipx.h
                    ipx_address
                    ipx_packet
                    ipx_interface
                    ipx_route
protocol.h
                    inet_protocol
route.h
                    rtable
snmp.h
                    ip_mib
                    icmp_mib
                    tcp_mib
                    udp_mib
sock.h
                    sock
                    proto

path: include/linux
fs.h
                    file
                    inode
                    file_operations
                    inode_operations
</code></pre><hr>
<p>Structure and memberships</p>
<pre><code>+---------------------------+              +------------------------+
|struct sk_buff             |              |struct sk_buff_head     |
+---------------------------+              +------------------------+
|struct sk_buff    *next;      |              |struct sk_buff  *next;  |
|struct sk_buff    *prev;      |              |struct sk_buff  *prev;  |
|struct sk_buff    *link3;     |              +------------------------+
|struct sk_buff *mem_addr;  |              
|struct sock *sk;           |              +--------------------------+ 
|struct device *dev;        |              |struct proto              |
|... ...                    |              +--------------------------+
+---------------------------+              |struct sock *sock_array[];|
                                           |int (*init) ();           |
                                           |int (*setsockopt) ();     |
+----------------------------+             |int (*read) ();           |
|struct device               |             |int (*write) ();          |
+----------------------------+             |int (*connect) ();        |
|struct device *next;        |             |int (*sendto) ();         |
|struct device *slave;       |             |int (*recvfrom)();        |
|struct sk_buff_head buffs[];|             |... ...                   |
|... ...                     |             +--------------------------+
+----------------------------+             

+----------------------------------+       +----------------------------------+
|struct socket                     |       |struct sock                       |
+----------------------------------+       +----------------------------------+
|short                type;        |       |struct sock *next;                |
|socket_state         state;       |       |struct sk_buff_head write_queue;  |
|long                 flags;       |       |struct sk_buff_head receive_queue;|
|struct proto_ops     *ops;        |       |struct proto *prot;               |
|void                 *data;       |       |struct socket *socket;            |
|struct socket        *conn;       |       |struct sk_buff *send_head;        |
|struct socket        *iconn;      |       |struct sk_buff *send_tail;        |
|struct socket        *next;       |       |struct sk_buff_head back_log;     |
|struct wait_queue    **wait;      |       |struct sk_buff *partial;          |
|struct inode         *inode;      |       |... ...                           |
|struct fasync_struct *fasync_list;|       +----------------------------------+
|... ...                           |       
+----------------------------------+       
                                           +-----------------------------+
+-----------------------+                  |struct file                  |
|struct proto_ops       |                  +-----------------------------+
+-----------------------+                  |struct file *f_next, *f_prev;|
|int    family();       |                  |struct inode *f_inode;       |
|int    (*create)();    |                  |struct file_operations *f_op;|
|int    (*dup)();       |                  |... ...                      |
|int    (*release)();   |                  +-----------------------------+
|int    (*bind)();      |                  
|int    (*connect)();   |                  +-----------------------------+
|int    (*socketpair)();|                  |struct file_operations       |
|int    (*accept)();    |                  +-----------------------------+
|int    (*getname)();   |                  |int (*open) ();              |
|int    (*read)();      |                  |int (*read) ();              |
|int    (*write)();     |                  |int (*write) ();             |
|int    (*select)();    |                  |int (*select) ();            |
|int    (*ioctl)();     |                  |int (*release) ();           |
|int    (*listen)();    |                  |... ...                      |
|int    (*send)();      |                  +-----------------------------+
|int    (*recv)();      |
|int    (*sendto)();    |                  +------------------------------+
|int    (*recvfrom)();  |                  |struct inode                  |
|int    (*shutdown)();  |                  +------------------------------+
|int    (*setsockopt)();|                  |struct inode *i_next, *i_prev;|
|int    (*getsockopt)();|                  |struct inode_operations *i_op;|
|int    (*fcntl)();     |                  |... ...                       |
+-----------------------+                  +------------------------------+
</code></pre>
      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/07/30/networkstack-important-structure/" data-id="ciqqpe1l8005ynmpvyv3mb420" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/kernel/">kernel</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/network/">network</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-networkstack-internet-protocol-suite" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/07/29/networkstack-internet-protocol-suite/" class="article-date">
  <time datetime="2013-07-28T16:00:00.000Z" itemprop="datePublished">2013-07-29</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/network/">network</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/07/29/networkstack-internet-protocol-suite/">NetworkStack Internet protocol suite</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="1-Introduce"><a href="#1-Introduce" class="headerlink" title="1. Introduce"></a>1. Introduce</h3><p>The Internet protocol suite and the layered protocol stack design were in use<br>before the OSI model was established. Since then, the TCP/IP model has been<br>compared with the OSI model in books and classrooms, which often results in<br>confusion because the two models use different assumptions and goals, including<br>the relative importance of strict layering.</p>
<h3 id="2-TCP-IP-Network-model"><a href="#2-TCP-IP-Network-model" class="headerlink" title="2. TCP/IP Network model"></a>2. TCP/IP Network model</h3><p>Layers in the internet protocol suite:( a four-layer model )  </p>
<pre><code>+------------------------+                         +--------+
|    Application layer   |                         |  Data  |
+------------------------+                         +--------+
            |
  +--------------------+                   +-------+--------+
  |   Transport layer  |                   |TCP/IP |  Data  |
  +--------------------+                   +-------+--------+
            |
  +-------------------+              +-----+-------+--------+
  |   Internet layer  |              | IP  |TCP/IP |  Data  |
  +-------------------+              +-----+-------+--------+
            |
    +---------------+       +--------+-----+-------+--------+
    |   Link layer  |       | Header | IP  |TCP/IP |  Data  |
    +---------------+       +--------+-----+-------+--------+
</code></pre><h3 id="Protocol-in-layers"><a href="#Protocol-in-layers" class="headerlink" title="Protocol in layers"></a>Protocol in layers</h3><p>Application layer</p>
<pre><code>DHCP
DHCPv6
DNS
FTP
HTTP*
IMAP
IRC
LDAP
MGCP
NNTP
BGP
NTP
POP
RPC
RTP
RTSP
RIP
SIP
SMTP
SNMP*
SOCKS
SSH
Telnet
TLS/SSL
XMPP
</code></pre><p>Transport layer</p>
<pre><code>TCP*
UDP*
DCCP
SCTP
RSVP
</code></pre><p>Internet layer</p>
<pre><code>IP(IPv4,IPv6)*
ICMP*
ICMPv6
ECN
IGMP
IPsec
</code></pre><p>Link layer</p>
<pre><code>ARP/InARP*
NDP
OSPF
Tunnels(L2TP)
PPP*
Media access control(Ethernet/DSL/ISDN/FDDI)
</code></pre><h3 id="3-Protocol-Format"><a href="#3-Protocol-Format" class="headerlink" title="3. Protocol Format"></a>3. Protocol Format</h3><p>IP - <a href="http://www.ietf.org/rfc/rfc791.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc791.txt</a>, page 11<br>TCP - <a href="http://www.ietf.org/rfc/rfc793.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc793.txt</a>, page 15<br>UDP - <a href="http://www.ietf.org/rfc/rfc768.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc768.txt</a>, page 1  </p>
<pre><code>0                   1                   2                   3   
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  IHL  |Type of Service|          Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |Flags|      Fragment Offset    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Live |    Protocol   |         Header Checksum       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source Address                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Destination Address                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

              Example Internet Datagram Header

0                   1                   2                   3   
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Acknowledgment Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data |           |U|A|P|R|S|F|                               |
| Offset| Reserved  |R|C|S|S|Y|I|            Window             |
|       |           |G|K|H|T|N|N|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |         Urgent Pointer        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             data                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        TCP Header Format

0      7 8     15 16    23 24    31  
+--------+--------+--------+--------+ 
|     Source      |   Destination   | 
|      Port       |      Port       | 
+--------+--------+--------+--------+ 
|                 |                 | 
|     Length      |    Checksum     | 
+--------+--------+--------+--------+ 
|                                     
|          data octets ...            
+---------------- ...                 

     User Datagram Header Format
</code></pre><h3 id="4-Protocol-links"><a href="#4-Protocol-links" class="headerlink" title="4. Protocol links"></a>4. Protocol links</h3><p>IP - Internet Protocol<br><a href="http://www.ietf.org/rfc/rfc791.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc791.txt</a></p>
<p>ARP - Address Resolution Protocol<br><a href="http://www.ietf.org/rfc/rfc826.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc826.txt</a><br><a href="http://en.wikipedia.org/wiki/Arp_protocol" target="_blank" rel="external">http://en.wikipedia.org/wiki/Arp_protocol</a></p>
<p>ICMP - Internet Control Message Protoco<br><a href="http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol" target="_blank" rel="external">http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol</a><br><a href="http://www.ietf.org/rfc/rfc792.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc792.txt</a></p>
<p>TCP - Transmission Control Protocol<br><a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol" target="_blank" rel="external">http://en.wikipedia.org/wiki/Transmission_Control_Protocol</a><br><a href="http://www.ietf.org/rfc/rfc793.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc793.txt</a></p>
<p>SMTP - Simple Mail Transfer Protocol<br><a href="http://www.ietf.org/rfc/rfc821.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc821.txt</a></p>
<p>FTP - File Transfer Protocol<br><a href="http://www.ietf.org/rfc/rfc958.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc958.txt</a></p>
<p>SNMP - Simple Network Management Protocol<br><a href="http://www.ietf.org/rfc/rfc1067.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc1067.txt</a></p>
<p>IGMP - Internet Group Management Protocol<br><a href="http://www.ietf.org/rfc/rfc3376.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc3376.txt</a><br><a href="http://en.wikipedia.org/wiki/Internet_Group_Management_Protocol" target="_blank" rel="external">http://en.wikipedia.org/wiki/Internet_Group_Management_Protocol</a></p>
<p>UDP - User Datagram Protocol<br><a href="http://en.wikipedia.org/wiki/User_Datagram_Protocol" target="_blank" rel="external">http://en.wikipedia.org/wiki/User_Datagram_Protocol</a><br><a href="http://www.ietf.org/rfc/rfc768.txt" target="_blank" rel="external">http://www.ietf.org/rfc/rfc768.txt</a></p>
<p>PPP - Point to point protocol<br><a href="http://en.wikipedia.org/wiki/Point-to-point_protocol" target="_blank" rel="external">http://en.wikipedia.org/wiki/Point-to-point_protocol</a><br><a href="http://tools.ietf.org/html/rfc1661" target="_blank" rel="external">http://tools.ietf.org/html/rfc1661</a></p>
<p>SMTP - Simple Mail Transfer Protocol<br><a href="http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol" target="_blank" rel="external">http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol</a>  </p>
<p>HTTP - Hypertext Transfer Protocol<br><a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol" target="_blank" rel="external">http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol</a>  </p>
<h3 id="5-Reference"><a href="#5-Reference" class="headerlink" title="5. Reference"></a>5. Reference</h3><ul>
<li><a href="http://en.wikipedia.org/wiki/Internet_protocol_suite" target="_blank" rel="external">Internet protocol suite</a></li>
<li><a href="http://zh.wikipedia.org/wiki/TCP/IP协议" target="_blank" rel="external">IP/IP协议</a></li>
<li><a href="http://www.linux-tutorial.info/modules.php?name=MContent&amp;obj=page&amp;pageid=142" target="_blank" rel="external">TCP-IP</a></li>
<li><a href="http://www.eventhelix.com/RealtimeMantra/Networking/#IP_-_Internet_Protocol" target="_blank" rel="external">TCP/IP and IMS Sequence Diagrams</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/07/29/networkstack-internet-protocol-suite/" data-id="ciqqpe1l3005vnmpvv1n867jq" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/network/">network</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-mac-address-swap-with-two-network-cards" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/07/19/mac-address-swap-with-two-network-cards/" class="article-date">
  <time datetime="2013-07-18T16:00:00.000Z" itemprop="datePublished">2013-07-19</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/network/">network</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/07/19/mac-address-swap-with-two-network-cards/">MAC address swap with two network cards</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="1-Problem"><a href="#1-Problem" class="headerlink" title="1. Problem"></a>1. Problem</h3><h4 id="1-1-When-network-setting-is-normal-found-that-MAC-address-was-swapped"><a href="#1-1-When-network-setting-is-normal-found-that-MAC-address-was-swapped" class="headerlink" title="1.1 When network setting is normal, found that MAC address was swapped."></a>1.1 When network setting is normal, found that MAC address was swapped.</h4><p>eth0 –&gt; 00:25:90:70:51:f1<br>eth1 –&gt; 00:25:90:70:51:f0</p>
<pre><code>[root@localhost ~]# ip a
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:25:90:70:51:f1 brd ff:ff:ff:ff:ff:ff
    inet 172.16.110.230/24 brd 172.16.110.255 scope global eth0
    inet6 fe80::225:90ff:fe70:51f1/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:25:90:70:51:f0 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::225:90ff:fe70:51f0/64 scope link 
       valid_lft forever preferred_lft forever
</code></pre><h4 id="1-2-But-when-made-a-bind-to-the-two-interface-it-was-correct"><a href="#1-2-But-when-made-a-bind-to-the-two-interface-it-was-correct" class="headerlink" title="1.2 But when made a bind to the two interface, it was correct."></a>1.2 But when made a bind to the two interface, it was correct.</h4><pre><code>[root@localhost ~]# ip a
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: &lt;BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:25:90:70:51:f0 brd ff:ff:ff:ff:ff:ff
3: eth1: &lt;BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:25:90:70:51:f1 brd ff:ff:ff:ff:ff:ff
4: bond0: &lt;BROADCAST,MULTICAST,MASTER,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UP 
    link/ether 00:25:90:70:51:f1 brd ff:ff:ff:ff:ff:ff
    inet 172.16.110.230/24 brd 172.16.110.255 scope global bond0
    inet6 fe80::225:90ff:fe70:51f1/64 scope link 
       valid_lft forever preferred_lft forever
</code></pre><p><strong>What had done when making the bind?</strong></p>
<p>Use command <code>dmesg</code>, we found that if there were words like “udev: renamed XXX to XXX”,<br>the MAC addree was correct matched to the interface. If not it was error.</p>
<p>before changed:</p>
<pre><code>[root@localhost ~]# dmesg | grep &quot;PCI Express&quot;
pciehp: PCI Express Hot Plug Controller Driver version: 0.4
e1000e 0000:00:19.0: eth0: (PCI Express:2.5GT/s:Width x1) 00:25:90:70:51:f1
e1000e 0000:04:00.0: eth1: (PCI Express:2.5GT/s:Width x1) 00:25:90:70:51:f0

[root@localhost ~]# dmesg | grep udev
udev: starting version 147
udev: starting version 147

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=&quot;eth0&quot;
BOOTPROTO=&quot;dhcp&quot;
HWADDR=&quot;00:25:90:70:51:F1&quot;
NM_CONTROLLED=&quot;yes&quot;
ONBOOT=&quot;no&quot;
TYPE=&quot;Ethernet&quot;
UUID=&quot;151c6203-2172-41b1-bd58-9bf03a2731e7&quot;

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=&quot;eth1&quot;
BOOTPROTO=&quot;dhcp&quot;
HWADDR=&quot;00:25:90:70:51:F0&quot;
NM_CONTROLLED=&quot;yes&quot;
ONBOOT=&quot;no&quot;
TYPE=&quot;Ethernet&quot;
UUID=&quot;a677dbc6-144a-455b-bcd3-6d8439560516&quot;

[root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules 
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x10d3 (e1000e) (custom name provided by external tool)
SUBSYSTEM==&quot;net&quot;, ACTION==&quot;add&quot;, DRIVERS==&quot;?*&quot;, ATTR{address}==&quot;00:25:90:70:51:f0&quot;, ATTR{type}==&quot;1&quot;, KERNEL==&quot;eth*&quot;, NAME=&quot;eth1&quot;

# PCI device 0x8086:0x1502 (e1000e) (custom name provided by external tool)
SUBSYSTEM==&quot;net&quot;, ACTION==&quot;add&quot;, DRIVERS==&quot;?*&quot;, ATTR{address}==&quot;00:25:90:70:51:f1&quot;, ATTR{type}==&quot;1&quot;, KERNEL==&quot;eth*&quot;, NAME=&quot;eth0&quot;
</code></pre><p>after changed:</p>
<pre><code>[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=&quot;eth0&quot;
BOOTPROTO=&quot;dhcp&quot;
HWADDR=&quot;00:25:90:70:51:F0&quot;
NM_CONTROLLED=&quot;yes&quot;
ONBOOT=&quot;no&quot;
TYPE=&quot;Ethernet&quot;
UUID=&quot;a677dbc6-144a-455b-bcd3-6d8439560516&quot;
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=&quot;eth1&quot;
BOOTPROTO=&quot;dhcp&quot;
HWADDR=&quot;00:25:90:70:51:F1&quot;
NM_CONTROLLED=&quot;yes&quot;
ONBOOT=&quot;no&quot;
TYPE=&quot;Ethernet&quot;
UUID=&quot;151c6203-2172-41b1-bd58-9bf03a2731e7&quot;
</code></pre><p>then reboot system.</p>
<pre><code>[root@localhost ~]# ip a
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth1: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:25:90:70:51:f1 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::225:90ff:fe70:51f1/64 scope link 
       valid_lft forever preferred_lft forever
3: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:25:90:70:51:f0 brd ff:ff:ff:ff:ff:ff
    inet 172.16.110.230/24 scope global eth0
    inet6 fe80::225:90ff:fe70:51f0/64 scope link 
       valid_lft forever preferred_lft forever

[root@localhost ~]# dmesg | grep udev
udev: starting version 147
udev: starting version 147
udev: renamed network interface eth0 to rename2
udev: renamed network interface eth1 to eth0
udev: renamed network interface rename2 to eth1

[root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules 
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x10d3 (e1000e) (custom name provided by external tool)
SUBSYSTEM==&quot;net&quot;, ACTION==&quot;add&quot;, DRIVERS==&quot;?*&quot;, ATTR{address}==&quot;00:25:90:70:51:f0&quot;, ATTR{type}==&quot;1&quot;, KERNEL==&quot;eth*&quot;, NAME=&quot;eth1&quot;

# PCI device 0x8086:0x1502 (e1000e) (custom name provided by external tool)
SUBSYSTEM==&quot;net&quot;, ACTION==&quot;add&quot;, DRIVERS==&quot;?*&quot;, ATTR{address}==&quot;00:25:90:70:51:f1&quot;, ATTR{type}==&quot;1&quot;, KERNEL==&quot;eth*&quot;, NAME=&quot;eth0&quot;

# PCI device 0x8086:0x1502 (e1000e) (custom name provided by external tool)
SUBSYSTEM==&quot;net&quot;, ACTION==&quot;add&quot;, DRIVERS==&quot;?*&quot;, ATTR{address}==&quot;00:25:90:70:51:f1&quot;, ATTR{type}==&quot;1&quot;, KERNEL==&quot;eth*&quot;, NAME=&quot;eth1&quot;

# PCI device 0x8086:0x10d3 (e1000e) (custom name provided by external tool)
SUBSYSTEM==&quot;net&quot;, ACTION==&quot;add&quot;, DRIVERS==&quot;?*&quot;, ATTR{address}==&quot;00:25:90:70:51:f0&quot;, ATTR{type}==&quot;1&quot;, KERNEL==&quot;eth*&quot;, NAME=&quot;eth0&quot;

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=&quot;eth0&quot;
BOOTPROTO=&quot;dhcp&quot;
HWADDR=&quot;00:25:90:70:51:F0&quot;
NM_CONTROLLED=&quot;yes&quot;
ONBOOT=&quot;no&quot;
TYPE=&quot;Ethernet&quot;
UUID=&quot;a677dbc6-144a-455b-bcd3-6d8439560516&quot;
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=&quot;eth1&quot;
BOOTPROTO=&quot;dhcp&quot;
HWADDR=&quot;00:25:90:70:51:F1&quot;
NM_CONTROLLED=&quot;yes&quot;
ONBOOT=&quot;no&quot;
TYPE=&quot;Ethernet&quot;
UUID=&quot;151c6203-2172-41b1-bd58-9bf03a2731e7&quot;
[root@localhost ~]#
</code></pre><h4 id="1-3-make-a-bind-to-the-network-MAC-is-correct-also"><a href="#1-3-make-a-bind-to-the-network-MAC-is-correct-also" class="headerlink" title="1.3 make a bind to the network, MAC is correct also."></a>1.3 make a bind to the network, MAC is correct also.</h4><pre><code>[root@localhost ~]# ip a
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth1: &lt;BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:25:90:70:51:f1 brd ff:ff:ff:ff:ff:ff
3: eth0: &lt;BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:25:90:70:51:f0 brd ff:ff:ff:ff:ff:ff
4: bond0: &lt;BROADCAST,MULTICAST,MASTER,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UP 
    link/ether 00:25:90:70:51:f0 brd ff:ff:ff:ff:ff:ff
    inet 172.16.110.230/24 brd 172.16.110.255 scope global bond0
    inet6 fe80::225:90ff:fe70:51f0/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 
</code></pre><p>delete the bind, still ok.</p>
<h4 id="1-4-How-for-group-ip"><a href="#1-4-How-for-group-ip" class="headerlink" title="1.4 How for group ip?"></a>1.4 How for group ip?</h4><p>group set to 172.16.110.233<br>eth0 set to 172.16.110.230<br>eth1 set to 172.16.110.231<br>from below we found the MAC was ok as hoped.</p>
<pre><code>[root@localhost ~]# ip a
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth1: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:25:90:70:51:f1 brd ff:ff:ff:ff:ff:ff
    inet 172.16.110.231/24 scope global eth1
    inet 172.16.110.233/24 scope global secondary eth1
    inet6 fe80::225:90ff:fe70:51f1/64 scope link 
       valid_lft forever preferred_lft forever
3: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:25:90:70:51:f0 brd ff:ff:ff:ff:ff:ff
    inet 172.16.110.230/24 scope global eth0
    inet 172.16.110.233/24 scope global secondary eth0
    inet6 fe80::225:90ff:fe70:51f0/64 scope link 
       valid_lft forever preferred_lft forever
</code></pre><h3 id="2-The-steps-to-modify-MAC-of-eth-look-like-as-below"><a href="#2-The-steps-to-modify-MAC-of-eth-look-like-as-below" class="headerlink" title="2. The steps to modify MAC of eth* look like as below"></a>2. The steps to modify MAC of eth* look like as below</h3><ol>
<li>OS boot </li>
<li>udev start </li>
<li>e1000e start, get eth* and MAC </li>
<li>check /etc/sysconfig/network-scripts/ifcfg-XXX, call shell script<br>/lib/udev/write_net_rules to generate rule file to /etc/udev/rules.d/70-persistent-net.rules<br>if MAC was not match with what got from e1000e (view udev source, you wil find udev)</li>
<li>udev rename eth* if there have “add” action in rule file /etc/udev/rules.d/70-persistent-net.rules</li>
</ol>
<h4 id="2-1-Check-lib-udev-write-net-rules"><a href="#2-1-Check-lib-udev-write-net-rules" class="headerlink" title="2.1 Check /lib/udev/write_net_rules"></a>2.1 Check /lib/udev/write_net_rules</h4><pre><code>36 RULES_FILE=&apos;/etc/udev/rules.d/70-persistent-net.rules&apos;
37 
38 . /lib/udev/rule_generator.functions
39 
40 find_all_ifcfg() {
41     local links=$1
42     local __sed_discard_ignored_files=&apos;/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d&apos;
43 
44     files=$(echo /etc/sysconfig/network-scripts/ifcfg-* \
45         | LC_ALL=C sed -e &quot;$__sed_discard_ignored_files&quot;)
46     for i in $files; do
47         (
48             . $i
49             [ -n &quot;$HWADDR&quot; ] &amp;&amp; [ &quot;${links%%[ \[\]0-9]*}&quot; = &quot;${DEVICE%%[ \[\]0-9]*}&quot; ] &amp;&amp; echo $DEVICE
50         )
51     done
52 }

70 write_rule() {
71         local match=&quot;$1&quot;
72         local name=&quot;$2&quot;
73         local comment=&quot;$3&quot;
74 
75         {
76         if [ &quot;$PRINT_HEADER&quot; ]; then
77                 PRINT_HEADER=
78                 echo &quot;# This file was automatically generated by the $0&quot;
79                 echo &quot;# program, run by the persistent-net-generator.rules rules file.&quot;
80                 echo &quot;#&quot;
81                 echo &quot;# You can modify it, as long as you keep each rule on a single&quot;
82                 echo &quot;# line, and change only the value of the NAME= key.&quot;
83         fi
84 
85         echo &quot;&quot;
86         [ &quot;$comment&quot; ] &amp;&amp; echo &quot;# $comment&quot;
87         echo &quot;SUBSYSTEM==\&quot;net\&quot;, ACTION==\&quot;add\&quot;$match, NAME=\&quot;$name\&quot;&quot;
88         } &gt;&gt; $RULES_FILE
89 }

153 write_rule &quot;$match&quot; &quot;$INTERFACE&quot; &quot;$COMMENT&quot;
</code></pre><h4 id="2-1-Check-udev-source"><a href="#2-1-Check-udev-source" class="headerlink" title="2.1 Check udev source"></a>2.1 Check udev source</h4><p>search the string we found in dmesg:</p>
<pre><code>[dennis@localhost udev]$ pwd
/home/dennis/Downloads/udev-174/udev
[dennis@localhost udev]$ grep -r -i --include &quot;*.c&quot; &quot;renamed&quot; .
./udev-rules.c:    /* handle device, renamed by external tool, returning new path */
./udev-event.c:    fprintf(f, &quot;&lt;30&gt;udevd[%u]: renamed network interface %s to %s\n&quot;,
./udev-event.c:                info(event-&gt;udev, &quot;renamed netif to &apos;%s&apos;\n&quot;, event-&gt;name);
[dennis@localhost udev]$ gvim udev-event.c 

static void rename_netif_kernel_log(struct ifreq ifr)
{
    int klog;
    FILE *f;

    klog = open(&quot;/dev/kmsg&quot;, O_WRONLY);
    if (klog &lt; 0)
        return;

    f = fdopen(klog, &quot;w&quot;);
    if (f == NULL) {
        close(klog);
        return;
    }

    fprintf(f, &quot;&lt;30&gt;udevd[%u]: renamed network interface %s to %s\n&quot;,
        getpid(), ifr.ifr_name, ifr.ifr_newname);
    fclose(f);
}
</code></pre><p>Because udev write log to /dev/kmsg, so we can got output like below:</p>
<pre><code>[root@localhost ~]# dmesg | grep udev
udev: starting version 147
udev: starting version 147
udev: renamed network interface eth0 to rename2
udev: renamed network interface eth1 to eth0
udev: renamed network interface rename2 to eth1
</code></pre><p>Continue tracking, found that <code>rename_netif_kernel_log</code> was called only by function: </p>
<pre><code>static int rename_netif(struct udev_event *event)
</code></pre><p>And who call <code>rename_netif</code>, the answer is only function: </p>
<pre><code>int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigmask)
</code></pre><p>From code segment from this function, we see:</p>
<pre><code>....
/* rename a new network interface, if needed */
if (udev_device_get_ifindex(dev) &gt; 0 &amp;&amp; strcmp(udev_device_get_action(dev), &quot;add&quot;) == 0 &amp;&amp;
    event-&gt;name != NULL &amp;&amp; strcmp(event-&gt;name, udev_device_get_sysname(dev)) != 0) {
    char syspath[UTIL_PATH_SIZE];
    char *pos;

    err = rename_netif(event);
....
</code></pre><p>from the name of function <code>udev_event_execute_rules</code> and cod segment, we can say,<br>udev rename ethXXX by the rules, where should have action like as “add”.</p>
<h4 id="2-2-Check-e1000e-source-found-nothing"><a href="#2-2-Check-e1000e-source-found-nothing" class="headerlink" title="2.2 Check e1000e source, found nothing"></a>2.2 Check e1000e source, found nothing</h4><h4 id="2-3-Check-dmesg-source-found-nothing"><a href="#2-3-Check-dmesg-source-found-nothing" class="headerlink" title="2.3 Check dmesg source, found nothing"></a>2.3 Check dmesg source, found nothing</h4><h4 id="2-4-Check-system-config-network-source-found-nothing"><a href="#2-4-Check-system-config-network-source-found-nothing" class="headerlink" title="2.4 Check system-config-network source, found nothing"></a>2.4 Check system-config-network source, found nothing</h4><h3 id="3-How-to-fix"><a href="#3-How-to-fix" class="headerlink" title="3. How to fix"></a>3. How to fix</h3><p>Use this shell scripts to check MAC</p>
<pre><code>#!/bin/sh

# check MAC address, if not match the correct interface, fix it.
file_eth0=/etc/sysconfig/network-scripts/ifcfg-eth0
file_eth1=/etc/sysconfig/network-scripts/ifcfg-eth1

if [ -e $file_eth0 ] &amp;&amp; [ -e $file_eth1 ]; then 
    # get MAC and UUID
    MAC0=$(grep HWADDR $file_eth0 | awk -F&apos;&quot;&apos; &apos;{print $(NF-1)}&apos;)
    MAC1=$(grep HWADDR $file_eth1 | awk -F&apos;&quot;&apos; &apos;{print $(NF-1)}&apos;)
    UUID0=$(grep UUID  $file_eth0 | awk -F&apos;&quot;&apos; &apos;{print $(NF-1)}&apos;)
    UUID1=$(grep UUID  $file_eth1 | awk -F&apos;&quot;&apos; &apos;{print $(NF-1)}&apos;)

    if [ &quot;$MAC0&quot; != &quot;&quot; ] &amp;&amp; [ &quot;$MAC1&quot; != &quot;&quot; ]; then
        # compare MAC
        compare_flag=0
        compare_flag=`echo $MAC0 $MAC1 | awk &apos;$1&gt;$2 {print 1}&apos;`
        if [ &quot;$compare_flag&quot; == &quot;1&quot; ]; then
            # swap MAC and UUID
            sed -i &apos;s/&apos;$MAC0&apos;/&apos;$MAC1&apos;/g&apos; $file_eth0
            sed -i &apos;s/&apos;$MAC1&apos;/&apos;$MAC0&apos;/g&apos; $file_eth1
            if [ &quot;$UUID0&quot; != &quot;&quot; ] &amp;&amp; [ &quot;$UUID1&quot; != &quot;&quot; ]; then
                sed -i &apos;s/&apos;$UUID0&apos;/&apos;$UUID1&apos;/g&apos; $file_eth0
                sed -i &apos;s/&apos;$UUID1&apos;/&apos;$UUID0&apos;/g&apos; $file_eth1
            else
                sed -i &apos;/UUID/d&apos; $file_eth0
                [ &quot;$UUID1&quot; != &quot;&quot; ] &amp;&amp; echo &quot;UUID=\&quot;$UUID1\&quot;&quot; &gt;&gt; $file_eth0
                sed -i &apos;/UUID/d&apos; $file_eth1
                [ &quot;$UUID0&quot; != &quot;&quot; ] &amp;&amp; echo &quot;UUID=\&quot;$UUID0\&quot;&quot; &gt;&gt; $file_eth1
            fi
        fi
    fi
fi
</code></pre><h3 id="4-Question"><a href="#4-Question" class="headerlink" title="4. Question"></a>4. Question</h3><ol>
<li>/etc/sysconfig/network-scripts/ifcfg-XXX were generated by who? system-config-network?</li>
</ol>
<h3 id="5-Reference"><a href="#5-Reference" class="headerlink" title="5. Reference"></a>5. Reference</h3><ul>
<li><a href="http://www.linuxfromscratch.org/lfs/view/development/chapter07/network.html" target="_blank" rel="external">7.2. General Network Configuration</a></li>
<li><a href="http://muzso.hu/2012/10/29/how-to-regenerate-the-etc-udev-rules.d-70-persistent-net.rules-file-on-debian-ubuntu" target="_blank" rel="external">How to regenerate the /etc/udev/rules.d/70-persistent-net.rules file on Debian/Ubuntu</a></li>
<li><a href="http://blog.csdn.net/gangban_lau/article/details/7209123" target="_blank" rel="external">udev is renaming my ethernet devices</a></li>
<li><a href="http://www.centos.org/docs/4/html/rhel-rg-en-4/s1-networkscripts-interfaces.html" target="_blank" rel="external">Red Hat Enterprise Linux 4: Reference Guide</a></li>
<li><a href="http://fedora.12.x6.nabble.com/Generating-ifcfg-eth0-from-scratch-td2280845.html" target="_blank" rel="external">Generating ifcfg-eth0 from scratch</a></li>
<li><a href="https://lists.fedoraproject.org/pipermail/users/2011-May/396591.html" target="_blank" rel="external">Generating ifcfg-eth0 from scratch</a></li>
<li><a href="http://brennan.id.au/04-Network_Configuration.html" target="_blank" rel="external">Chapter 4 - Network Configuration</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/07/19/mac-address-swap-with-two-network-cards/" data-id="ciqqpe1kz005snmpvyvbgknp4" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/network/">network</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-steven-jobs-stanford-commencement-address-june-2005" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/07/16/steven-jobs-stanford-commencement-address-june-2005/" class="article-date">
  <time datetime="2013-07-15T16:00:00.000Z" itemprop="datePublished">2013-07-16</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/others/">others</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/07/16/steven-jobs-stanford-commencement-address-june-2005/">Steven Jobs: Stanford commencement address, June 2005</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>From <a href="http://english.koolearn.com/20111008/478099.html" target="_blank" rel="external">http://english.koolearn.com/20111008/478099.html</a></p>
<p>This is the text of the Commencement address by Steven Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005.</p>
<p>I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth be told, I never graduated from college. This is the closest I’ve ever gotten to a college graduation. Today I want to tell you three stories from my life. That’s it. No big deal. Just three stories.</p>
<h3 id="The-first-story-is-about-connecting-the-dots"><a href="#The-first-story-is-about-connecting-the-dots" class="headerlink" title="The first story is about connecting the dots."></a>The first story is about connecting the dots.</h3><p>I dropped out of Reed College after the first 6 months, but then stayed around as a drop-in for another 18 months or so before I really quit. So why did I drop out?</p>
<p>It started before I was born. My biological mother was a young, unwed college graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided at the last minute that they really wanted a girl. So my parents, who were on a waiting list, got a call in the middle of the night asking: “We have an unexpected baby boy; do you want hime?” They said: “Of course.” My biological mother later found out that my mother had never graduated from college and that my father had never graduated from high school. She refused to sign the final adoption papers. She only relented a few months later when my parents promised that I would someday go to college.</p>
<p>And 17 years later I did go to college. But I naively chose a college that was almost as expensive as Stanford, and all of my working-class parents’ savings were being spent on my college tuition. After six months, I couldn’t see the value in it. I had no idea what I wanted to do with my life and no idea how college was going to help me figure it out. And here I was spending add of the money my parents had saved their entire life. So I decided to drop out and trust that it would all work out OK. It was pretty scary at the time, but looking back it was one of the best decisions I ever made. The minute I dropped out I could stop taking the required classes that didn’t interest me, and begin dropping in on the ones that looked interesting.</p>
<p>It wasn’t all romantic. I didn’t have a dorm room, so I slept on the floor in friends’ rooms. I returned coke bottles for the 5 cent; deposites to buy food with, and I would walk the 7 miles across town every Sunday night to get one good meal a week at the Hare Krishna temple. I loved it. And much of what I stumbled into by following my curiosity and intuition turned out to be priceless later on. Let me give you one example.</p>
<p>Reed College at that time offered perhaps the best calligraphy instruction in the country. Throughout the campus every poster, every label on every drawer, was beautifully hand calligraphed. Because I had dropped out and didn’t have to take the normal classes. I decided to take a calligraphy class to learn how to do this. I learned about serif and san serif typefaces, about varying the amount of space between different letter combinations, about what makes great typography great. It was beautiful, historical, artistically subtle in a way that science can’t capture and I found it fascinating.</p>
<p>None of this had even a hope of any practical application in my life. But ten years later, when we were designing the first Macintosh computer, it all came back to me. And we designed it all into the Mac. It was the first computer with beautiful typography. If I had never dropped in on that single course in college, the Mac would have never had multiple typefaces or proportionally space fonts. And since Windows just copied the Mac, its likely that no personal computer would have them. If I had never dropped out, I would have never dropped in on this calligraphy class, and personal computers might not have the wonderful typography that they do. Of course it was impossible to connect the dots looking forward when I was in college. But it was very, very clear looking backwards ten years later.</p>
<p>Again, you can’t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something – your gut, destiny, life, karma, wahtever. This approach has never let me down, and it has made all the difference in my life.</p>
<h3 id="My-second-story-is-about-love-and-loss"><a href="#My-second-story-is-about-love-and-loss" class="headerlink" title="My second story is about love and loss."></a>My second story is about love and loss.</h3><p>I was lucky – I found what I loved to do early in life. Woz and I started Apple in my parents garage when I was 20. We worked hard, and in 10 years Apple had grown from just the two of us in a garage into a $2 billion company with over 4000 employees. We had just released out finest creation – the Macintosh – a year earlier, and I had just turned 30. And then I got fired. How can you get fired from a company you started? Well, as Apple grew we hired someone who I thought was very talented to run the company with me, and for the first year or so things went well. But then our visions of the future began to diverge and eventually we had a falling out. When we did, our Board of Directors sided with him. So at 30 I was out. And very publicly out. What had been the focus of my entire adult life was gone, and it was devastating.</p>
<p>I really didn’t know what to do for a few months. I felt that I had let the previous generation of entrepreneurs down - that I had dropped the baton as it was being passed to me. I met with David Packard and Bob Noyce and tried to apologize for screwing up so badly. I was a very public failure, and I even thought about running away from the valley. But something slowly began to dawn on me – I still loved what I did. The turn of events at Apple had not changed that one bit. I had been rejected, but I was still in love. And so I decided to start over.</p>
<p>I didn’t seen it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.</p>
<p>During the next five years, I started a company named NeXT, another company named Pixar, and fell in love with an amazing woman who would become my wife. Pixar went on to create the worlds first computer animated feature film, Toy Story, and is now the most successful animation studio in the world. In a remarkable turn of events, Apple bought NeXT, I returned to Apple, and the technology we developed at NeXT is at the heart of Apple’s current renaissance. And Laurene and I have a wonderful family together.</p>
<p>I’m pretty sure none of this would have happened if I hadn’t been fired from Apple. It was awful tasting medicine, but I guess the patient needed it.</p>
<p>Sometimes life hits you in the head with a brick. Don’t lose faith. I’m convinced that the only thing that kept me going was that I loved what I did. You’ve got to find what you love. And that is as true for you work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truely satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven’t found it yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don’t settle.</p>
<h3 id="My-third-story-is-about-death"><a href="#My-third-story-is-about-death" class="headerlink" title="My third story is about death"></a>My third story is about death</h3><p>When I was 17, I read a quote that went something like: “If you live each day as if it was your last, someday you’ll most certainly be right.” It made an impression on me, and since then, for the past 33 years, I have looked in the mirror every morning and asked myself: “If today were the last day of my life, would I want to do what I am about to do today?” And whenever the answer has been “No” for too many days in a row, I know I need to change something.</p>
<p>Remembering that I’ll be dead soon is the most important tool I’ve ever encountered to help me make the big choices in life. Because almost everything – all external expectations, all pride, all fear of embarrassment or failure - these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked. There is no reason not to follow your heart.</p>
<p>About a year ago I was diagnosed with cancer. I had a scan at 7:30 in the morning, and it clearly showed a tumor on my pancreas. I didn’t even know what a pancreas was. The doctors told me this was almost certainly a type of cancer that is incurable, and what I should expect to live no longer than three to six months. My doctor advised me to go home and get my affairs in order, which is doctor’s code for  prepare to die. It means to try to tell your kids everything you thought you’d had the next 10 years to tell them in just a few months. It means to make sure everything is buttoned up so that it will be easy as possible for your family. It means to say your goodbyes.</p>
<p>I lived with that diagnosis all day. Later that evening I had a biopsy, where they stuck anendoscope down my throat, through my stomach and into my intestines, put a needle into my pancreas and got a few cells from the tumor. I was sedated, but my wife, who  was there, told me that when they viewed the cells under a microscope the doctors started crying because it turned out to be a very rare from of pancreatic cancer that is curable with surgery. I had surgery and I’m fine now.</p>
<p>This was the closet I’ve been to facing death, and I hope its the closet I get for a few more decades. Having lived through it, I can now say this to you with a bit more certainty than when death was a useful but purely intellectual concept:</p>
<p>No one wants to die. Even people who want to go to heaven don’t want to die to get there. And yet death is the destination we all share. No one has ever escaped it. And that is as it should be, because Death is very likely the single best invention of Life. It is Life’s change agent. It clears out the old to make way for the new. Right now the new is you, but someday not too long from now, you will gradually become the old and be cleared away. Sorry to be so dramatic, but it is quite true.</p>
<p>Your tiems is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma – which is living with the results of other people’s thinking. Don’t let the noise of other’s opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.</p>
<p>When I was young, there was an amazing publication called The Whole Earth Catalog, which was one of the bibles of my generation. It was created by a fellow named Stewart Brand not far from here in Menlo Park, and he brought it to life with his poetic touch. This was in the late 1960’s, before personal computers and desktop publishing, so it was all made with typewriters, scissors, and polaroid cameras. It was sort of like Goolge in paperback form, 35 years before Google came along: it was idealistic, and overflowing with neat tools and great notions.</p>
<p>Stewart and his team  put out several issues of the Whole Earth Catalog, and then when it had run its course, they put out a final issue. It was the mid-1970s, and I was your age. On the back cover of their final issue was photograph of an early morning country road, the kind you might find yourself hitchhiking on if you were so adventurous. Beneath it were the words: “Stay Hungry. Stay Foolish.” It was their farewell message as they signed off. Stay Hungry. Stay Foolish. And I have always wished that for myself. And now, as your graduate to begin anew, I wish that for you.</p>
<p>Stay Hungry. Stay Foolish.</p>
<p>Thank you all very much.</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/07/16/steven-jobs-stanford-commencement-address-june-2005/" data-id="ciqqpe1kw005qnmpv82lbj9zq" class="article-share-link">Partager</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-novels-three-peaks" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/07/11/novels-three-peaks/" class="article-date">
  <time datetime="2013-07-10T16:00:00.000Z" itemprop="datePublished">2013-07-11</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/others/">others</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/07/11/novels-three-peaks/">novels Three Peaks</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>From <http: free-online-novels.com="" books="" three="" peaks="" first="" edition="" web="" v1_0="" 2012.pdf=""></http:></p>
<p>#Part One </p>
<p>#Everest</p>
<p>##Chapter One </p>
<p>Just outside of Namche Bazaar, Nepal</p>
<p>present day </p>
<p>Sunita was breathing hard.</p>
<p>Not good. The air up here made one light-headed. Nepal had eight of the world’s ten tallest mountain peaks, but right now, Sunita’s thoughts were a lot higher.</p>
<p>“Oh jesus!” she cried, as she kept moving along the narrow path. “Save me! Save me!”</p>
<p>Near breathless, she repeated it in her heart rather than out loud.</p>
<p>If the Maoist Army caught up with her, she could be executed for being an American spy. She should know. She used to be a Lance Corporal in the army. As for being an American spy, her only crime was to have been caught reading a Christian pamphlet that one of her fellow officers had given her.</p>
<p>It told the story of a man who had lived and then died … and then lived again. She had read it through several times. The little pamphlet had now been lost in flight. Which was a shame because she would have liked to know more.</p>
<p>At least there was one person she knew who could tell her more. </p>
<p>But her immediate objective was to survive.</p>
<p>“On, Jesus!” she cried. It was more of a whisper. “Save me!”</p>
<p>Joliet, Illinois</p>
<p>present day </p>
<p>“With awesome deeds you answer us with righteousness, God our salvation, the hope of all the ends of the earth and of the farthest seas.” Chris surveyed his congregation. The knew this scripture by heart. It was his signature scripture. “Who by his power formed the mountains and being armed with strength …”</p>
<p>There, now they could all relax. His sermon had included a reference to mountain. He continued reading Psalm 65, but even his own mind was wandering.</p>
<p>As a self-centred, outspoken  25-year-old, he had climbed Mount Everest.</p>
<p>Unfortunately, he wasn’t the first person to do so, and even though the achievement was commendable compared to what most people did in their lifetimes, he wasn’t exactly overwhelmed with offers from cereal companies to feature his face on their boxes of wheatie squares.</p>
<p>But a local church had approached him.</p>
<p>Would he be interested in sharing his experience with their youth group? No scripture references necessary. The youth pastor would have a few things to say about God and mountains and then Chris could go ahead and speak about Everest.</p>
<p>For lack of anything better to do, he had accepted.</p>
<p>That had been ten years ago. Since then, he had worked his way up from becoming a part-time assistant youth pastor, to a full-time assistant youth pastor, to a full-time youth pastor, and now, to a full-time assistant pastor.</p>
<p>And it was only a matter of time before he was the pastor. </p>
<p>Everyone thought of it as Chris’s church. He always made sure to include a scriptural reference to mountains, an admonition to scale seemingly impossible problems with perseverance, and a few anecdotes about his own climb (granted, he often had to adjust them slightly to suit the message). In fact, out on the signboard of the community church was a mountain peak beside its name. That had been added when he had built up the youth program from an apathetic twenty teenagers to an enthusiastic two hundred, or so.</p>
<p>But it had become increasingly challenging to handle the youth group. They were easily inspired. They wanted to climb mountains. The greatest difficulty for Chris was to take it from the abstract to the concrete. Climb what mountain? He had never come up with a good answer. He had found it easier to talk to the adults. The adults, he found, didn’t want to climb any mountains. Metaphorically, the seemed more inclined to seek out a bypass, to find the path of least exertion.</p>
<p>“The kid want to mission trip,” said Danny, comming into Chris’s office and sitting down. “All the big churches do it and we’ve got the youth for it.”</p>
<p>Chris nodded, only half-listening. He was scrolling through his emails.</p>
<p>Danny, the pastor, was an energetic man in his mid-fifties. He made no secret of the fact that his heart was with missions. In fact, that was why Chris was so sure that he would be the pastor in short time. Danny would probably turn into a full-time missionary in the near future. Chris wouldn’t be surprised if he was just using the kids as an excuse for a trip to Bolivia, or some other mission field that he would lead them to.</p>
<p>“We’re thinking of Nepal,” said Danny.</p>
<p>“Nepal?” Now Danny had Chris’s attention. “It’s not exactly friendly to the gospel.”</p>
<p>“That’s why the kids want to do it,” said Danny. “A group of them approached me and said they think it’s what God wants them to do.”</p>
<p>In his head, Chris disagreed. They had heard him speak more than once about his experience climbing Everest. Everest was in  Nepal. It wasn’t God. It was just a natural outcome of being part of a church that made a mountain its logo.</p>
<p>“Well,” said Chris, his eyes straying back to his computer screen; despite that most of the emails were spam. “All the best to them. I take it Randy will lead them.”</p>
<p>Randy was the youth pastor, an enthusiastic man in his late twenties, recently married.</p>
<p>Danny shook his head.</p>
<p>“Susan just found out she’s pregnant.” Susan was Randy’s new wife. “He won’t be going anywhere for a while. Besides, the kids want you to lead it.” Chris’s eyes widened. Danny grinned. “I think some of them are hoping you’ll lead them on a little side trip up Everest.”</p>
<p>“That would be easier than a mission trip,” said Chris. “I don’t know much about the place. I mean, I spent more time in base camp than I did in Kathmandu, but I remember a lot of temples and prayer wheels and things. And guys going around in colourful robes and there were these poles people put up with scarves on them. One of the guides told me the were prayers and the wind blew the requests up to heaven. Or something like that. To be honest, I didn’t really pay attention.”</p>
<p>“I’ve been doing a little reading on the topic, ever since the kids came to me,” said Danny. “From what I understand, the real difficulty is the Maoist army that runs the country. They came to power in 2008 and promised to establish a democratic republic. The country is predominantly Hindu, but the prayer wheels that you saw would have been part of the failth of the country’s Buddhist minority, about 10%, as I recall. In any case, the Christians there face opposition from all sides.”</p>
<p>“Sounds fun,” said Chris grimly. “You avoid all that if you just go to climb the mountains.”</p>
<p>Danny nodded.</p>
<p>“I haven’t told the kis this, but evangelism there is seriously frowned on. If the indigenous people do it, they could be fined or imprisoned. If foreigners do it, it’s less severe, eviction from the country. But I think if some of the parents go online and start looking into it, they’ll never let their kids out sof the country.”</p>
<p>Chris was relieved.</p>
<p>This mission trip wouldn’t get off the ground.</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/07/11/novels-three-peaks/" data-id="ciqqpe1ku005onmpvoxvvbva6" class="article-share-link">Partager</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-android-develepment" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/06/28/android-develepment/" class="article-date">
  <time datetime="2013-06-27T16:00:00.000Z" itemprop="datePublished">2013-06-28</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/others/">others</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/06/28/android-develepment/">android develepment</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>##1. Introduce</p>
<p>##2. Download</p>
<h3 id="2-1-Download-Tools"><a href="#2-1-Download-Tools" class="headerlink" title="2.1 Download Tools"></a>2.1 Download Tools</h3><p>Download android SDK from <a href="http://developer.android.com/sdk/index.html" target="_blank" rel="external">http://developer.android.com/sdk/index.html</a>, ADT<br>Bundle is contain SDK and Eclipse, Linux 64-bit platform use<br><a href="http://dl.google.com/android/adt/adt-bundle-linux-x86_64-20130522.zip" target="_blank" rel="external">http://dl.google.com/android/adt/adt-bundle-linux-x86_64-20130522.zip</a>, if just<br>want to download SDK only, download <a href="http://dl.google.com/android/android-sdk_r22.0.1-linux.tgz" target="_blank" rel="external">http://dl.google.com/android/android-sdk_r22.0.1-linux.tgz</a><br>for Linux 32 &amp; 64-bit, other platform please referent the download page instruction. </p>
<h3 id="2-2-Setting-Environment"><a href="#2-2-Setting-Environment" class="headerlink" title="2.2 Setting Environment"></a>2.2 Setting Environment</h3><p>Install android develep plugin:  </p>
<pre><code>https://dl-ssl.google.com/android/eclipse/
</code></pre><p>##3. Workflow</p>
<p>If you want to run you application on really device, you should read this page<br><a href="http://developer.android.com/tools/device.html" target="_blank" rel="external">http://developer.android.com/tools/device.html</a>.</p>
<p>##4. Create Your First Application</p>
<p>##5. Run sample</p>
<p>##6. Improve your skills</p>
<p>##7. Reference:  </p>
<ul>
<li><a href="http://developer.android.com/index.html" target="_blank" rel="external">Android Developers</a></li>
<li><a href="http://developer.android.com/training/basics/firstapp/index.html" target="_blank" rel="external">Build your</a></li>
<li><a href="http://fedoraproject.org/wiki/HOWTO_Setup_Android_Development" target="_blank" rel="external">HOWTO Setup Android Development</a></li>
<li><a href="http://www.isspy.com/fedora-13-下配置android开发环境/" target="_blank" rel="external">Fedora 13 下配置Android开发环境</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/06/28/android-develepment/" data-id="ciqqpe1kn005lnmpvax06jwst" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/android/">android</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-use-sg_ses" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/06/20/use-sg_ses/" class="article-date">
  <time datetime="2013-06-19T16:00:00.000Z" itemprop="datePublished">2013-06-20</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/storage/">storage</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/06/20/use-sg_ses/">use sg_ses</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>##1.Introduction</p>
<p>The sg_ses utility enables a user “to manage and sense the state of the power<br>supplies, cooling devices, displays, indicators, individual drives, and other<br>non-SCSI elements installed in an enclosure”.<br>The SCSI Enclosure Services standards (most recent is SES-2 ANSI INCITS 448-2008<br>) and the latest draft (ses3r03.pdf at www.t10.org) describe the format that the<br>sg_ses utility expects to find in a SES device (“logical unit” or “process”)</p>
<p>##2.Command Tools</p>
<p>sg_map - displays mapping between linux sg and other SCSI devices </p>
<p>sg_ses - send controls and fetch status from a SCSI EnclosureServices (SES) device </p>
<p>sg  = SCSI Generic<br>ses = SCSI Enclosure Service</p>
<p>##3.Use command<br>query mapping of expander and device name</p>
<pre><code>[root@ ~]# sg_map
/dev/sg0  /dev/sda
/dev/sg1  /dev/sdb
/dev/sg2  /dev/sdc
/dev/sg3  /dev/sdd
/dev/sg4  /dev/sde
/dev/sg5  /dev/sdf
/dev/sg6  /dev/sdg
/dev/sg7
/dev/sg8  /dev/sdh
/dev/sg9  /dev/sdi
/dev/sg10  /dev/sdj
/dev/sg11  /dev/sdk
/dev/sg12  /dev/sdl
/dev/sg13  /dev/sdm
/dev/sg14

[root@ ~]# sg_map -i
/dev/sg0  /dev/sda  ATA       SanDisk SSD U100  10.5
/dev/sg1  /dev/sdb  ATA       Hitachi HUA72201  A3EA
/dev/sg2  /dev/sdc  ATA       Hitachi HUA72201  A39C
/dev/sg3  /dev/sdd  ATA       ST2000VX000-9YW1  CV13
/dev/sg4  /dev/sde  ATA       Hitachi HUA72201  A3EA
/dev/sg5  /dev/sdf  ATA       ST2000VX000-9YW1  CV13
/dev/sg6  /dev/sdg  ATA       ST2000VX000-9YW1  CV13
/dev/sg7  GOOXI     Bobcat            0d00
/dev/sg8  /dev/sdh  ATA       ST2000VX000-9YW1  CV13
/dev/sg9  /dev/sdi  ATA       ST2000VX000-9YW1  CV13
/dev/sg10  /dev/sdj  ATA       ST2000VX000-9YW1  CV13
/dev/sg11  /dev/sdk  ATA       ST2000VX000-9YW1  CV13
/dev/sg12  /dev/sdl  ATA       Hitachi HDE72101  A31B
/dev/sg13  /dev/sdm  ATA       Hitachi HDE72101  A3AA
/dev/sg14  GOOXI     Bobcat            0d00
</code></pre><p>There are two expanders, /dev/sg7 and /dev/sg14, to show the only expanders<br>list, use below command:</p>
<pre><code>[root@ ~]# sg_map | awk &apos;{if($2==&quot;&quot;){print $1}}&apos;
/dev/sg7
/dev/sg14
</code></pre><p>We also can use ls to find expanders:</p>
<pre><code>[root@ ~]# ls /dev/sg* -l
crw-rw---- 1 root disk 21,  0 Jun 18 22:54 /dev/sg0
crw-rw---- 1 root disk 21,  1 Jun 19 17:33 /dev/sg1
crw-rw---- 1 root disk 21, 15 Jun 19 23:33 /dev/sg15
crw-rw---- 1 root disk 21, 16 Jun 19 23:33 /dev/sg16
crw-rw---- 1 root disk 21, 17 Jun 19 23:33 /dev/sg17
crw-rw---- 1 root disk 21, 18 Jun 19 23:33 /dev/sg18
crw-rw---- 1 root disk 21,  2 Jun 18 22:55 /dev/sg2
crw-rw---- 1 root disk 21,  3 Jun 18 22:55 /dev/sg3
crw-rw---- 1 root disk 21,  4 Jun 19 17:33 /dev/sg4
crw-rw---- 1 root disk 21,  5 Jun 18 22:55 /dev/sg5
crw-rw---- 1 root disk 21,  6 Jun 20 17:49 /dev/sg6
crw-rw---- 1 root root 21,  7 Jun 18 22:55 /dev/sg7
crw-rw---- 1 root disk 21,  8 Jun 20 21:46 /dev/sg8
crw-rw---- 1 root disk 21,  9 Jun 20 21:46 /dev/sg9

[root@ ~]# ls /dev/sg* -l |awk &apos;{if($4==&quot;root&quot;){print $10}}&apos;
/dev/sg7
</code></pre><p>To view the pages of /dev/sg7</p>
<pre><code>[root@ ~]# sg_ses -p 0 /dev/sg7
  GOOXI     Bobcat            0d00
    enclosure services device
Supported diagnostic pages:
  Supported diagnostic pages [0x0]
  Configuration (SES) [0x1]
  Enclosure status/control (SES) [0x2]
  String In/Out (SES) [0x4]
  Threshold In/Out (SES) [0x5]
  Element descriptor (SES) [0x7]
  Additional element status (SES-2) [0xa]
  Supported SES diagnostic pages (SES-2) [0xd]
  Download microcode (SES-2) [0xe]
  Subenclosure nickname (SES-2) [0xf]
</code></pre><p>To view the enclosure status </p>
<pre><code>[root@ ~]# sg_ses -p 2 /dev/sg7
  GOOXI     Bobcat            0d00
    enclosure services device
Enclosure status diagnostic page:
  INVOP=0, INFO=1, NON-CRIT=0, CRIT=0, UNRECOV=0
  generation code: 0x0
  status descriptor list
    Element type: Array device slot, subenclosure id: 0
     Overall 0 descriptor:
       Predicted failure=0, Disabled=0, Swap=0, status: Unsupported
       OK=0, Reserved device=0, Hot spare=0, Cons check=0
       In crit array=0, In failed array=0, Rebuild/remap=0, R/R abort=0
       App client bypass A=0, Do not remove=0, Enc bypass A=0, Enc bypass B=0
       Ready to insert=0, RMV=0, Ident=0, Report=0
       App client bypass B=0, Fault sensed=0, Fault reqstd=0, Device off=0
       Bypassed A=0, Bypassed B=0, Dev bypassed A=0, Dev bypassed B=0
     Element 0 descriptor:
       Predicted failure=0, Disabled=0, Swap=0, status: Not installed
       OK=0, Reserved device=0, Hot spare=0, Cons check=0
       In crit array=0, In failed array=0, Rebuild/remap=0, R/R abort=0
       App client bypass A=0, Do not remove=0, Enc bypass A=0, Enc bypass B=0
       Ready to insert=0, RMV=0, Ident=0, Report=0
       App client bypass B=0, Fault sensed=0, Fault reqstd=0, Device off=0
       Bypassed A=0, Bypassed B=0, Dev bypassed A=0, Dev bypassed B=0
     Element 1 descriptor:
       Predicted failure=0, Disabled=0, Swap=0, status: OK
       OK=0, Reserved device=0, Hot spare=0, Cons check=0
       In crit array=0, In failed array=0, Rebuild/remap=0, R/R abort=0
       App client bypass A=0, Do not remove=0, Enc bypass A=0, Enc bypass B=0
       Ready to insert=0, RMV=0, Ident=0, Report=0
       App client bypass B=0, Fault sensed=0, Fault reqstd=0, Device off=0
       Bypassed A=0, Bypassed B=0, Dev bypassed A=0, Dev bypassed B=0

     ...

     Element 27 descriptor:
       Predicted failure=0, Disabled=0, Swap=0, status: Not installed
       OK=0, Reserved device=0, Hot spare=0, Cons check=0
       In crit array=0, In failed array=0, Rebuild/remap=0, R/R abort=0
       App client bypass A=0, Do not remove=0, Enc bypass A=0, Enc bypass B=0
       Ready to insert=0, RMV=0, Ident=0, Report=0
       App client bypass B=0, Fault sensed=0, Fault reqstd=0, Device off=0
       Bypassed A=0, Bypassed B=0, Dev bypassed A=0, Dev bypassed B=0
</code></pre><p>To view the enclosure status by specify index </p>
<pre><code>[root@ ~]# sg_ses -p 2 -I 27 /dev/sg7
  GOOXI     Bobcat            0d00
    enclosure services device
Enclosure status diagnostic page:
  INVOP=0, INFO=1, NON-CRIT=0, CRIT=0, UNRECOV=0
  generation code: 0x0
  status descriptor list
     Element 27 descriptor:
       Predicted failure=0, Disabled=0, Swap=0, status: Not installed
       OK=0, Reserved device=0, Hot spare=0, Cons check=0
       In crit array=0, In failed array=0, Rebuild/remap=0, R/R abort=0
       App client bypass A=0, Do not remove=0, Enc bypass A=0, Enc bypass B=0
       Ready to insert=0, RMV=0, Ident=0, Report=0
       App client bypass B=0, Fault sensed=0, Fault reqstd=0, Device off=0
       Bypassed A=0, Bypassed B=0, Dev bypassed A=0, Dev bypassed B=0
</code></pre><p>view enclosure Additional element status<br>From result info, we can map the slot num with element index, also SAS address</p>
<pre><code>[root@ ~]# sg_ses -p 0xa /dev/sg7
  GOOXI     Bobcat            0d00
    enclosure services device
Additional element status diagnostic page:
  generation code: 0x0
  additional element status descriptor list
      Element index: 0
        Transport protocol: SAS
        number of phys: 1, not all phys: 0, device slot number: 21
        phy index: 0
          device type: no device attached
          initiator port for:
          target port for:
          attached SAS address: 0x0000000000000000
          SAS address: 0x0000000000000000
          phy identifier: 0x0
      Element index: 1
        Transport protocol: SAS
        number of phys: 1, not all phys: 0, device slot number: 20
        phy index: 0
          device type: no device attached
          initiator port for:
          target port for: SATA_device
          attached SAS address: 0x500605b0000272bf
          SAS address: 0x500605b0000272a1
          phy identifier: 0x0

      ...

      Element index: 27
        Transport protocol: SAS
        number of phys: 1, not all phys: 0, device slot number: 22
        phy index: 0
          device type: no device attached
          initiator port for:
          target port for:
          attached SAS address: 0x0000000000000000
          SAS address: 0x0000000000000000
          phy identifier: 0x0

# Also, we can show the specify index additional element status 
[root@ ~]# sg_ses -p 0xa -I 26 /dev/sg7
  GOOXI     Bobcat            0d00
    enclosure services device
Additional element status diagnostic page:
  generation code: 0x0
  additional element status descriptor list
      Element index: 26
        Transport protocol: SAS
        number of phys: 1, not all phys: 0, device slot number: 23
        phy index: 0
          device type: no device attached
          initiator port for:
          target port for: SATA_device
          attached SAS address: 0x500605b0000272bf
          SAS address: 0x500605b0000272ba
          phy identifier: 0x0
</code></pre><p>This command get a simple output:</p>
<pre><code># command explain:
# grep -E &apos;Element|slot&apos;     search by an extended regular expression 
# sed &apos;N;s/\n//&apos;             join two lines together
# awk &apos;{print $3,$15}&apos;       printf third and 15th column

# out format: element_index slot_number 
[root@ ~]# sg_ses -p 0xa /dev/sg7 |grep -E &apos;slot|Element&apos; |sed &apos;N;s/\n//&apos; |awk &apos;{print $3,$15}&apos;
0 21
1 20
2 16
3 12
4 24
5 25
6 26
7 27
8 8
9 4
10 0
11 1
12 3
13 2
14 7
15 6
16 5
17 11
18 10
19 9
20 15
21 14
22 13
23 19
24 18
25 17
26 23
27 22

# out format: slot_number element_index
[root@ ~]# sg_ses -p 0xa /dev/sg7 |grep -E &apos;slot|Element&apos; |sed &apos;N;s/\n//&apos; |awk &apos;{print $15,$3}&apos; |sort -n
0 10
1 11
2 13
3 12
4 9
5 16
6 15
7 14
8 8
9 19
10 18
11 17
12 3
13 22
14 21
15 20
16 2
17 25
18 24
19 23
20 1
21 0
22 27
23 26
24 4
25 5
26 6
27 7
</code></pre><p>we can get the mapping relation between slot number and SAS address:</p>
<pre><code># 0x0000000000000000 means there is not exist physical disk
[root@ ~]# sg_ses -p 0xa /dev/sg7 |grep -E &apos;slot|  SAS address&apos; |sed &apos;N;s/\n//&apos; |awk &apos;{print $12,$15}&apos; |sort -n
0 0x50014ee300165dde
1 0x50014ee3556bb24a
2 0x50014ee30016698a
3 0x50014ee300166666
4 0x50014ee300165dea
5 0x50014ee3aac1019e
6 0x0000000000000000
7 0x0000000000000000
8 0x0000000000000000
9 0x0000000000000000
10 0x0000000000000000
11 0x0000000000000000
12 0x0000000000000000
13 0x0000000000000000
14 0x0000000000000000
15 0x0000000000000000
16 0x500605b0000272a2
17 0x500605b0000272b9
18 0x500605b0000272b8
19 0x500605b0000272b7
20 0x500605b0000272a1
21 0x0000000000000000
22 0x0000000000000000
23 0x500605b0000272ba
24 0x500148500018fba0
25 0x500148500018fba0
26 0x0000000000000000
27 0x500148500018fba0

[root@ ~]# sg_ses -p 0xa /dev/sg7 |grep -E &apos;slot|  SAS address&apos; |sed &apos;N;s/\n//&apos; |awk &apos;{print $12,$15}&apos; |sort -n |grep -v 0x0000000000000000
0 0x50014ee300165dde
1 0x50014ee3556bb24a
2 0x50014ee30016698a
3 0x50014ee300166666
4 0x50014ee300165dea
5 0x50014ee3aac1019e
16 0x500605b0000272a2
17 0x500605b0000272b9
18 0x500605b0000272b8
19 0x500605b0000272b7
20 0x500605b0000272a1
23 0x500605b0000272ba
24 0x500148500018fba0
25 0x500148500018fba0
27 0x500148500018fba0
</code></pre><p>##4.Control LED</p>
<p>Table 72 – Array Device Slot control element<br>(Taken from <a href="http://sg.danny.cz/sg/sg_ses.html" target="_blank" rel="external">http://sg.danny.cz/sg/sg_ses.html</a>)</p>
<pre><code>+-Byte\Bit-+---7----+---6----+---5----+---4----+---3----+---2----+---1----+---0----+
+     0    +                           COMMON CONTROL                              +
+----------+--------+--------+--------+--------+--------+--------+--------+--------+
+          + RQST   + RQST   + RQST   + RQST   + RQST   +RQST IN +RQST    + RQST   +
+     1    + OK     + RSVD   + HOT    + CONS   + IN CRIT+FAILED  +REBUILD/+ R/R    +
+          +        + DEVICE + SPARE  + CHECK  + ARRAY  +ARRAY   +REMAP   + ABORT  +
+----------+--------+--------+--------+--------+--------+--------+--------+--------+
+     2    + RQST   + DO NOT +Reserved+ RQST   + RQST   + RQST   + RQST   +Reserved+
+          + ACTIVE + REMOVE +        +MISSING + INSERT + REMOVE + IDENT  +        +
+----------+--------+--------+--------+--------+--------+--------+--------+--------+
+     3    +     Reserved    + RQST   + DEVICE + ENABLE + ENABLE +     Reserved    +
+          +                 + FAULT  +  OFF   + BYP A  + BYP B  +                 +
+----------+--------+--------+--------+--------+--------+--------+--------+--------+
</code></pre><p>Insert harddisk, Blue LED light on, it is controlled by hardware.</p>
<p>Read/write harddisk, Blue LED flash, it is controlled by hardware also.</p>
<pre><code>--index   : Element index (not slot index)
--set     : set   a status of specify element
--clear   : clear a status of specify element
/dev/sg5  : expander position (There is problem, how to position which disk
            belong to which expander?)

##raid failed: (Blue LED light on, green LED flash)
sg_ses --index=27 --set=1:2:1 /dev/sg5

##rebuild: (Red LED flash)
sg_ses --index=27 --set=1:1:1 /dev/sg5

##miss:
sg_ses --index=27 --set=2:4:1 /dev/sg5

##indent: (Blue and Green LED flash)
sg_ses --index=27 --set=2:1:1 /dev/sg5

##disk fault: (Red LED light on)
sg_ses --index=27 --set=fault  /dev/sg5
or
sg_ses --index=27 --set=3:5:1  /dev/sg5

all the upon command can use --clear option to clean status.

The latter three invocations use a numerical description of the field whose 
format is &lt;start_byte&gt;:&lt;start_bit&gt;[:&lt;number_of_bits&gt;] . 
The &lt;number_of_bits&gt; defaults to 1 when it is not given.(try to understand 
it with table 72)

#clear status
sg_ses --index 27 --clear=1:1 /dev/sg5
sg_ses --index 27 --clear=1:2 /dev/sg5
sg_ses --index 27 --clear=3:5 /dev/sg5
</code></pre><p>Some problems:  </p>
<ul>
<li>How can I know what color the LED would be when the command done?</li>
<li>Is there exist one command that can clear all status? (I do not want to use the<br>clear command again and again, it is too ugly. or it is not need to do these?)</li>
</ul>
<p>##5.Other command tools</p>
<p>获取磁盘信息的命令工具:</p>
<pre><code>磁盘所包含的信息

硬件信息:型号、物理类型、序列号、温度、转速、工作速率、磁盘LU、
         磁盘端口SAS地址、厂商、固件、LED灯状态等
位置信息:Enclosure、slot
逻辑信息:运行状态(在线、空闲热备盘、重构盘)、逻辑类型(成员盘、空闲热备盘、
         空闲盘)、所属RAID组、所属卷组
SMART信息


#sg_map
显示sg设备和sd设备的映射关系

#sginfo –l
获取sg设备的信息

#sg_ses –p 0xa /dev/sg18
获取磁盘槽位号、磁盘端口SAS地址

#ll  /dev/disk/by-path
获取磁盘端口SAS地址、磁盘盘符

#sg_inq  -p  0x83  /dev/sdq
磁盘LU、磁盘端口SAS地址

#udevinfo –a –p /block/sdq
获取磁盘的信息

#udevinfo –q all –n /dev/sdq
获取磁盘的详细信息

#scsi_id  -x –g –s /block/sdq 
获取磁盘详细信息

#smartctl  -H /dev/sdb
查看磁盘健康状态

#smartctl -a  /dev/sdb
#smartctl -A /dev/sdb
查看磁盘SMART信息和温度

#smartctl -x  /dev/sdb
显示磁盘所有信息，包括SAS地址等
</code></pre><p>output status in raw format:</p>
<pre><code>[root@ ~]# sg_ses -p 0x2 /dev/sg7 -r
    00 00 00 00 00 00 00 00  05 04 00 00 01 04 00 00
    01 01 00 00 05 00 00 00  05 00 00 00 05 00 00 00
    05 00 00 00 05 00 00 00  05 00 00 00 05 00 00 00
    01 00 00 00 01 00 00 00  01 00 00 00 01 00 00 00
    05 00 00 00 05 00 00 00  05 00 00 00 05 00 00 00
    05 00 00 00 05 00 00 00  05 00 00 00 05 00 00 00
    05 00 00 00 11 00 00 00  11 00 00 00 11 00 00 00
    01 00 00 00 05 00 00 00

byte 1 to 8 is general description, element description if start from 8th byte.

From ses3r05.pdf Table 63 -- Element status code field (Page 70)
01    0k            Element is installed and no error conditions are known.
05    Not Installed Element is not installed in enclosure.
09~0F Reserved

So, the first 4 bytes start from 8th byte is 05 04 00 00, means not disk installed 
and its status is &quot;IN FAILED ARRAY&quot;.(See ses3r05.pdf page 77 Table 73)

The second 4 bytes is 01 04 00 00, means that disk is ok and status is &quot;IN FAILED ARRAY&quot;.

The third 4 bytes is 01 01 00 00, means that disk ok and &quot;R/R ABORT&quot;.

The 20th 4bytes is 11 00 00 00, means disk ok. 

Notice that the frist byte 11 is equal to 01, look at Table 63, we can see 
that element status code only depends on low 4 bits (0~3th bits for ELEMENT 
STATUS CODE, 4th bit is SWAP, 5th is DISABLED, 6th is PRDFAIL, 7th is Reserved)
</code></pre><p>look ses3r05.pdf for more details:</p>
<pre><code>Table 12 — Enclosure Status diagnostic page -- Page 30
Table 13 — Status descriptor                -- Page 32
Table 62 — Status element format            -- Page 70
Table 63 — ELEMENT STATUS CODE field        -- Page 70
Table 72 — Array Device Slot control element-- Page 76
Table 73 — Array Device Slot status element -- Page 77
</code></pre><p>##7.Reference</p>
<ul>
<li><a href="http://linux.die.net/man/8/sg_map" target="_blank" rel="external">man sg_map</a></li>
<li><a href="http://sg.danny.cz/sg/sg_ses.html" target="_blank" rel="external">_<strong>The sg_ses utility</strong>_</a></li>
<li><a href="http://rpm.pbone.net/index.php3/stat/45/idpl/9494420/numer/8/nazwa/sg_ses" target="_blank" rel="external">man sg_ses howto</a></li>
<li><a href="http://sg.danny.cz/sg/sg3_utils.html" target="_blank" rel="external">The Linux sg3_utils package</a></li>
<li><a href="http://sg.danny.cz/sg/" target="_blank" rel="external">The Linux SCSI Generic (sg) Driver</a></li>
<li><a href="https://github.com/zhurongze/notes/blob/master/hardware/使用SES协议实现磁盘定位.md" target="_blank" rel="external"><em><strong>使用SES协议实现磁盘定位</strong></em></a></li>
<li><a href="http://way4ever.com/?p=324" target="_blank" rel="external">磁盘信息管理所需要的技术</a></li>
<li><a href="http://www.t10.org/" target="_blank" rel="external">T10 technical Committee</a></li>
<li><a href="http://www.t10.org/cgi-bin/ac.pl?t=f&amp;f=ses3r05.pdf" target="_blank" rel="external">SCSI Enclosure Services - 3 (SES-3) ses3r05.pdf</a></li>
<li><a href="https://github.com/bvanassche/sg3_utils/blob/master/src/sg_ses.c" target="_blank" rel="external">sg_ses github source</a></li>
<li><a href="http://pic.dhe.ibm.com/infocenter/powersys/v3r1m5/index.jsp?topic=/p7eal/diskdriveenclosureleds.htm" target="_blank" rel="external">7031-D24 or 7031-T24 disk-drive enclosure LEDs</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/06/20/use-sg_ses/" data-id="ciqqpe1ki005inmpv0w6wkg1j" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/storage/">storage</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-iscsi-and-implementation" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/06/07/iscsi-and-implementation/" class="article-date">
  <time datetime="2013-06-06T16:00:00.000Z" itemprop="datePublished">2013-06-07</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/storage/">storage</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/06/07/iscsi-and-implementation/">iSCSI and implementation</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Introduce"><a href="#Introduce" class="headerlink" title="Introduce"></a>Introduce</h3><p>iSCSI（发音为 /аɪskʌzi/）（iSCSI = internet Small Computer System Interface ）<br>又稱為IP-SAN，是一种基于因特网及SCSI-3协议下的存储技术，<br>由IETF提出，並於2003年2月11日成為正式的標準。<br>与传统的SCSI技术比较起来，iSCSI技术有以下三个革命性的变化：</p>
<pre><code>1. 把原來只用於本機的SCSI協同透過TCP/IP网络傳送，使连接距离可作无限的地域延伸
2. 连接的服务器数量无限（原來的SCSI-3的上限是15）
3. 由于是服务器架构，因此也可以实现在线扩容以至动态部署
</code></pre><p>iSCSI利用了TCP/IP的port 860 和 3260 作为沟通的渠道。透过两部计算机之间利用iSCSI<br>的协议来交换SCSI命令，让计算机可以透过高速的局域网集线来把SAN模拟成为本地的储存装置。</p>
<p>The overall structure of an iSCSI  PDU is as follows:</p>
<pre><code>Byte/     0       |       1       |       2       |       3       |
   /              |               |               |               |
  |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  +---------------+---------------+---------------+---------------+
 0/ Basic Header Segment (BHS)                                    /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
48/ Additional Header Segment 1 (AHS)  (optional)                 /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
  / Additional Header Segment 2 (AHS)  (optional)                 /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
 ----
  +---------------+---------------+---------------+---------------+
  / Additional Header Segment n (AHS)  (optional)                 /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
 ----
  +---------------+---------------+---------------+---------------+
 k/ Header-Digest (optional)                                      /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
 l/ Data Segment(optional)                                        /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
 m/ Data-Digest (optional)                                        /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
</code></pre><p>The format of the BHS(fixed size, 48 bytes ) is:</p>
<pre><code>Byte/     0       |       1       |       2       |       3       |
   /              |               |               |               |
  |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  +---------------+---------------+---------------+---------------+
 0|.|I| Opcode    |F|  Opcode-specific fields                     |
  +---------------+---------------+---------------+---------------+
 4|TotalAHSLength | DataSegmentLength                             |
  +---------------+---------------+---------------+---------------+
 8| LUN or Opcode-specific fields                                 |
  +                                                               +
12|                                                               |
  +---------------+---------------+---------------+---------------+
16| Initiator Task Tag                                            |
  +---------------+---------------+---------------+---------------+
20/ Opcode-specific fields                                        /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
48
</code></pre><p>For request PDUs, the I bit set to 1 is an immediate delivery marker.</p>
<p>Initiator opcodes defined in this specification are:</p>
<pre><code>0x00 NOP-Out
0x01 SCSI Command (encapsulates a SCSI Command Descriptor Block)
0x02 SCSI Task Management function request
0x03 Login Request
0x04 Text Request
0x05 SCSI Data-Out (for WRITE operations)
0x06 Logout Request
0x10 SNACK Request
0x1c-0x1e Vendor specific codes
</code></pre><p>Target opcodes are:</p>
<pre><code>0x20 NOP-In
0x21 SCSI Response - contains SCSI status and possibly sense
     information or other response information.
0x22 SCSI Task Management function response
0x23 Login Response
0x24 Text Response
0x25 SCSI Data-In - for READ operations.
0x26 Logout Response
0x31 Ready To Transfer (R2T) - sent by target when it is ready
     to receive data.
0x32 Asynchronous Message - sent by target to indicate certain
     special conditions.
0x3c-0x3e Vendor specific codes
0x3f Reject
</code></pre><p>When set to 1 it indicates the final (or only) PDU of a sequence.</p>
<p>Some opcodes operate on a specific Logical Unit.  The Logical Unit<br>Number (LUN) field identifies which Logical Unit.  If the opcode does<br>not relate to a Logical Unit, this field is either ignored or may be<br>used in an opcode specific way.  The LUN field is 64-bits and should<br>be formatted in accordance with [SAM2].  For example, LUN[0] from<br>[SAM2] is BHS byte 8 and so on up to LUN[7] from [SAM2], which is BHS<br>byte 15.</p>
<p>The general format of an AHS is:</p>
<pre><code>Byte/     0       |       1       |       2       |       3       |
   /              |               |               |               |
  |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  +---------------+---------------+---------------+---------------+
 0| AHSLength                     | AHSType       | AHS-Specific  |
  +---------------+---------------+---------------+---------------+
 4/ AHS-Specific                                                  /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
 x
</code></pre><p>The format of the SCSI Command PDU is:</p>
<pre><code>Byte/     0       |       1       |       2       |       3       |
   /              |               |               |               |
  |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
  +---------------+---------------+---------------+---------------+
 0|.|I| 0x01      |F|R|W|. .|ATTR | Reserved                      |
  +---------------+---------------+---------------+---------------+
 4|TotalAHSLength | DataSegmentLength                             |
  +---------------+---------------+---------------+---------------+
 8| Logical Unit Number (LUN)                                     |
  +                                                               +
12|                                                               |
  +---------------+---------------+---------------+---------------+
16| Initiator Task Tag                                            |
  +---------------+---------------+---------------+---------------+
20| Expected Data Transfer Length                                 |
  +---------------+---------------+---------------+---------------+
24| CmdSN                                                         |
  +---------------+---------------+---------------+---------------+
28| ExpStatSN                                                     |
  +---------------+---------------+---------------+---------------+
32/ SCSI Command Descriptor Block (CDB)                           /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
48/ AHS (Optional)                                                /
  +---------------+---------------+---------------+---------------+
 x/ Header Digest (Optional)                                      /
  +---------------+---------------+---------------+---------------+
 y/ (DataSegment, Command Data) (Optional)                        /
 +/                                                               /
  +---------------+---------------+---------------+---------------+
 z/ Data Digest (Optional)                                        /
  +---------------+---------------+---------------+---------------+
</code></pre><h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference:"></a>Reference:</h3><ul>
<li><a href="http://en.wikipedia.org/wiki/ISCSI" target="_blank" rel="external">iSCSI</a></li>
<li><a href="http://www.ietf.org/rfc/rfc3720.txt" target="_blank" rel="external">RFC 3720 TEXT format</a></li>
<li><a href="http://tools.ietf.org/html/rfc3720" target="_blank" rel="external">RFC 3720 HTML format</a></li>
<li><a href="http://www.sansky.net/article/2007-12-03-iscsi-storage.html" target="_blank" rel="external">iSCSI存储技术全攻略</a></li>
<li><a href="http://sourceforge.net/projects/iscsitarget/" target="_blank" rel="external">iscsitarget</a></li>
<li><a href="http://sourceforge.net/projects/pytarget/" target="_blank" rel="external">pyTarget</a></li>
<li><a href="http://jscsi.sourceforge.net/" target="_blank" rel="external">jSCSI is a cross-platform Java implementation of an iSCSI initiator</a></li>
<li><a href="https://github.com/disy/jSCSI" target="_blank" rel="external">jSCSI on github</a></li>
<li><a href="http://stgt.sourceforge.net/" target="_blank" rel="external">TGT</a></li>
<li><a href="http://slimphpiscsipan.sourceforge.net" target="_blank" rel="external">Slim PHP iSCSI Panel for Centos</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/06/07/iscsi-and-implementation/" data-id="ciqqpe1ke005enmpv6j1xb9za" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/iscsi/">iscsi</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/storage/">storage</a></li></ul>

    </footer>
  </div>
  
</article>


  


  <nav id="page-nav">
    <a class="extend prev" rel="prev" href="/page/11/">&laquo; __('prev')</a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/10/">10</a><a class="page-number" href="/page/11/">11</a><span class="page-number current">12</span><a class="page-number" href="/page/13/">13</a><a class="page-number" href="/page/14/">14</a><span class="space">&hellip;</span><a class="page-number" href="/page/18/">18</a><a class="extend next" rel="next" href="/page/13/">__('next') &raquo;</a>
  </nav>
</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Catégories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/blog/">blog</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/database/">database</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/english/">english</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/kernel/">kernel</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/language/">language</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/linux/">linux</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/math/">math</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/network/">network</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/others/">others</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/person/">person</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/program/">program</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/source/">source</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/storage/">storage</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/tools/">tools</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/windows/">windows</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Mot-clés</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/FAQ/">FAQ</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/IRC/">IRC</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Translation/">Translation</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/android/">android</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/api/">api</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/assembly/">assembly</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/awk/">awk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/batch/">batch</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/blog/">blog</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/book/">book</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c++</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cache/">cache</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/crash/">crash</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/database/">database</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/debug/">debug</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dot/">dot</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/driver/">driver</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/emacs/">emacs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/exploit/">exploit</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/file-system/">file system</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/filesystem/">filesystem</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/flowchart/">flowchart</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gcc/">gcc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/google/">google</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/graphviz/">graphviz</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hosts/">hosts</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/iscsi/">iscsi</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javascript/">javascript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/job/">job</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/json/">json</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/kernel/">kernel</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lisp/">lisp</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lua/">lua</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/makefile/">makefile</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/malloc/">malloc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/math/">math</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/maxima/">maxima</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memory/">memory</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memory-overflow/">memory overflow</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mtrace/">mtrace</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/netdisk/">netdisk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/network/">network</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/others/">others</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pandoc/">pandoc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/performance/">performance</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/person/">person</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/">protobuf</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rsync/">rsync</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sed/">sed</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/shell/">shell</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/skype/">skype</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sms/">sms</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/source/">source</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ssh/">ssh</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/stack/">stack</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/storage/">storage</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/study/">study</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/svn/">svn</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sync/">sync</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/test/">test</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/time/">time</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/tools/">tools</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/valgrind/">valgrind</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vi/">vi</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vim/">vim</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/virtual/">virtual</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wget/">wget</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/windows/">windows</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wireshark/">wireshark</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/write/">write</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/xml/">xml</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Nuage de mot-clés</h3>
    <div class="widget tagcloud">
      <a href="/tags/FAQ/" style="font-size: 10px;">FAQ</a> <a href="/tags/IRC/" style="font-size: 10px;">IRC</a> <a href="/tags/Translation/" style="font-size: 13px;">Translation</a> <a href="/tags/android/" style="font-size: 10px;">android</a> <a href="/tags/api/" style="font-size: 10px;">api</a> <a href="/tags/assembly/" style="font-size: 10px;">assembly</a> <a href="/tags/awk/" style="font-size: 11px;">awk</a> <a href="/tags/batch/" style="font-size: 14px;">batch</a> <a href="/tags/blog/" style="font-size: 10px;">blog</a> <a href="/tags/book/" style="font-size: 10px;">book</a> <a href="/tags/c/" style="font-size: 16px;">c</a> <a href="/tags/c/" style="font-size: 19px;">c++</a> <a href="/tags/cache/" style="font-size: 10px;">cache</a> <a href="/tags/crash/" style="font-size: 10px;">crash</a> <a href="/tags/database/" style="font-size: 17px;">database</a> <a href="/tags/debug/" style="font-size: 12px;">debug</a> <a href="/tags/dot/" style="font-size: 10px;">dot</a> <a href="/tags/driver/" style="font-size: 10px;">driver</a> <a href="/tags/emacs/" style="font-size: 11px;">emacs</a> <a href="/tags/exploit/" style="font-size: 10px;">exploit</a> <a href="/tags/file-system/" style="font-size: 10px;">file system</a> <a href="/tags/filesystem/" style="font-size: 12px;">filesystem</a> <a href="/tags/flowchart/" style="font-size: 10px;">flowchart</a> <a href="/tags/gcc/" style="font-size: 10px;">gcc</a> <a href="/tags/git/" style="font-size: 12px;">git</a> <a href="/tags/google/" style="font-size: 11px;">google</a> <a href="/tags/graphviz/" style="font-size: 11px;">graphviz</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a> <a href="/tags/hosts/" style="font-size: 10px;">hosts</a> <a href="/tags/iscsi/" style="font-size: 14px;">iscsi</a> <a href="/tags/java/" style="font-size: 10px;">java</a> <a href="/tags/javascript/" style="font-size: 10px;">javascript</a> <a href="/tags/job/" style="font-size: 10px;">job</a> <a href="/tags/json/" style="font-size: 10px;">json</a> <a href="/tags/kernel/" style="font-size: 14px;">kernel</a> <a href="/tags/linux/" style="font-size: 14px;">linux</a> <a href="/tags/lisp/" style="font-size: 10px;">lisp</a> <a href="/tags/lua/" style="font-size: 10px;">lua</a> <a href="/tags/makefile/" style="font-size: 10px;">makefile</a> <a href="/tags/malloc/" style="font-size: 10px;">malloc</a> <a href="/tags/math/" style="font-size: 11px;">math</a> <a href="/tags/maxima/" style="font-size: 10px;">maxima</a> <a href="/tags/memory/" style="font-size: 11px;">memory</a> <a href="/tags/memory-overflow/" style="font-size: 10px;">memory overflow</a> <a href="/tags/mtrace/" style="font-size: 10px;">mtrace</a> <a href="/tags/netdisk/" style="font-size: 10px;">netdisk</a> <a href="/tags/network/" style="font-size: 20px;">network</a> <a href="/tags/others/" style="font-size: 18px;">others</a> <a href="/tags/pandoc/" style="font-size: 10px;">pandoc</a> <a href="/tags/performance/" style="font-size: 16px;">performance</a> <a href="/tags/person/" style="font-size: 11px;">person</a> <a href="/tags/protobuf/" style="font-size: 11px;">protobuf</a> <a href="/tags/python/" style="font-size: 10px;">python</a> <a href="/tags/rsync/" style="font-size: 10px;">rsync</a> <a href="/tags/sed/" style="font-size: 11px;">sed</a> <a href="/tags/shell/" style="font-size: 15px;">shell</a> <a href="/tags/skype/" style="font-size: 11px;">skype</a> <a href="/tags/sms/" style="font-size: 10px;">sms</a> <a href="/tags/source/" style="font-size: 11px;">source</a> <a href="/tags/ssh/" style="font-size: 10px;">ssh</a> <a href="/tags/stack/" style="font-size: 10px;">stack</a> <a href="/tags/storage/" style="font-size: 15px;">storage</a> <a href="/tags/study/" style="font-size: 10px;">study</a> <a href="/tags/svn/" style="font-size: 11px;">svn</a> <a href="/tags/sync/" style="font-size: 10px;">sync</a> <a href="/tags/test/" style="font-size: 11px;">test</a> <a href="/tags/time/" style="font-size: 10px;">time</a> <a href="/tags/tools/" style="font-size: 16px;">tools</a> <a href="/tags/valgrind/" style="font-size: 10px;">valgrind</a> <a href="/tags/vi/" style="font-size: 10px;">vi</a> <a href="/tags/vim/" style="font-size: 14px;">vim</a> <a href="/tags/virtual/" style="font-size: 11px;">virtual</a> <a href="/tags/wget/" style="font-size: 10px;">wget</a> <a href="/tags/windows/" style="font-size: 11px;">windows</a> <a href="/tags/wireshark/" style="font-size: 10px;">wireshark</a> <a href="/tags/write/" style="font-size: 13px;">write</a> <a href="/tags/xml/" style="font-size: 10px;">xml</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">July 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/">April 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">March 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/02/">February 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">November 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/10/">October 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/09/">September 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/08/">August 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/07/">July 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/06/">June 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/03/">March 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/02/">February 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/01/">January 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/12/">December 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/11/">November 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/09/">September 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/08/">August 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/07/">July 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/06/">June 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/05/">May 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/04/">April 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/03/">March 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/11/">November 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/10/">October 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/09/">September 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/08/">August 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/07/">July 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/06/">June 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/05/">May 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/04/">April 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/03/">March 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/02/">February 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/01/">January 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/12/">December 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/09/">September 2012</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Articles récents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/07/17/how-to-implement-malloc/">如何实现一个malloc</a>
          </li>
        
          <li>
            <a href="/2016/07/17/study-grep-more/">grep工作原理</a>
          </li>
        
          <li>
            <a href="/2016/07/17/2016-04-13-malloc/">malloc</a>
          </li>
        
          <li>
            <a href="/2016/04/27/include-what-you-use/">使用IWYU整理头文件引用</a>
          </li>
        
          <li>
            <a href="/2016/04/24/understand-gcc-assembly-output/">understand gcc assembly output</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2016 Matrix207<br>
      Propulsé by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>

  </div>
</body>
</html>